Re: [PATCH] checkpatch: prefer = {} initializations to = {0}

From: Dan Carpenter
Date: Mon Aug 16 2021 - 15:05:54 EST


On Mon, Aug 16, 2021 at 08:23:45AM +0100, Russell King (Oracle) wrote:
> > That's out of date. It changed in C11. Both = { 0 } and = { } will
> > clear out struct holes. The = { } GCC extension has always initialized
> > struct holes.
> >
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf
> >
> > For partial initializations then all the padding is zeroed.
> > Unfortunately if you fully initialize the struct then padding is not
> > initialized.
>
> If we're going to discuss which C standard applies to the kernel,
> then...
>
> As Kbuild passes -std=gnu89, the kernel expects C89 behaviour with
> GNU extensions from the compiler, both C99 and C11 are not that
> relevant, although the GNU extensions include some bits from these
> standards.

That's fine. The GCC implementation has always been okay. The question
is if we could rely on it going forward so now that it's part of the
spec that's very reassuring.

regards,
dan carpenter