Re: [PATCH] staging: lustre: ldlm: use designated initializers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 20, 2016 at 11:07 AM, Dan Carpenter
<dan.carpenter@xxxxxxxxxx> wrote:
> On Tue, Dec 20, 2016 at 02:57:17PM +0000, Hammond, John wrote:
>> "{ NULL }" is valid ISO C, but unfortunately "{}" is not.
>
> In the kernel we don't care.  We use lots of GCC extensions.

We depend on the compiler to do "incomplete zero-initialization" of
structures that are not mentioned in an initializer. The reason { NULL
} works is because the first field in the structure can take a NULL
value, and then the rest are zero-initialized by the compiler. { } is
the same thing, but doesn't use ordered initialization. If this style
is truly unacceptable to you, then { .somefield = NULL } can work, or
as you point out, if it's being initialized later, the static
initializer can be dropped entirely.

-Kees

-- 
Kees Cook
Nexus Security
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux