Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Mar 2018 09:54:05 -0600
From:      Benjamin Kaduk <bjkfbsd@gmail.com>
To:        Ed Maste <emaste@freebsd.org>
Cc:        Eitan Adler <eadler@freebsd.org>, svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers <src-committers@freebsd.org>
Subject:   Re: svn commit: r330602 - head/sys/compat/cloudabi
Message-ID:  <CAJ5_RoD%2BQVJYK9%2B5OzTJoHA2gVVTWRL4yNYNZ7SKMkn70pvevw@mail.gmail.com>
In-Reply-To: <CAPyFy2DOrHNs2BEQVqJYBGxT4iiA3ms_crXcX=q0wXr=63ddug@mail.gmail.com>
References:  <201803071447.w27Elh7C053393@repo.freebsd.org> <CAPyFy2DOrHNs2BEQVqJYBGxT4iiA3ms_crXcX=q0wXr=63ddug@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 7, 2018 at 9:44 AM, Ed Maste <emaste@freebsd.org> wrote:

> On 7 March 2018 at 09:47, Eitan Adler <eadler@freebsd.org> wrote:
> > Author: eadler
> > Date: Wed Mar  7 14:47:43 2018
> > New Revision: 330602
> > URL: https://svnweb.freebsd.org/changeset/base/330602
> >
> > Log:
> >   sys/cloudabi: Avoid relying on GNU specific extensions
> >
> >   An empty initializer list is not technically valid C grammar.
> >
> >   MFC After:    1 week
> >
> > -       cloudabi_fdstat_t fsb = {};
> > +       cloudabi_fdstat_t fsb = {0};
>
> In practice it appears initializing via { 0 } also zeros any padding
> in the struct, but I do not believe it's required by the C standard.
> Perhaps a language lawyer can weigh in?
>
> Commenting on this commit just because it's highlighted by this
> change; I do not believe there's a difference between the GNU
> extension { } and { 0 } here.
>
>
The C spec says that if an incomplete initializer is given, then all other
fields
of the structure are initialized to zero.  The state of padding is
unspecified,
whether a complete or incomplete initializer is given.

The "issue" being "fixed" here is that the formal C grammar does not
admit a totally empty initializer, so at least one element of the
initializer
needs to be given in order to satisfy the grammar.  This is pretty silly,
and the extension to allow a totally empty initializer a quite natural one
to make.

-Ben



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ5_RoD%2BQVJYK9%2B5OzTJoHA2gVVTWRL4yNYNZ7SKMkn70pvevw>