On Wed, Jan 09, 2019 at 11:15:58AM -0800, Linus Torvalds wrote: > On Wed, Jan 9, 2019 at 11:01 AM Ramsay Jones > <ramsay@xxxxxxxxxxxxxxxxxxxx> wrote: > > > > Ahem, so yes, both gcc and clang allow this (I just tested it), but > > my reading of the C99 standard lead me to believe that this is not > > valid C. (Not that it really matters). > > Interesting. Looking at the kernel, we actually have a lot of them, ie > > [torvalds@i7 linux]$ git grep 'struct.*= {[:space:]*}' | wc > 1105 6766 81616 > > although admittedly we also have a fair amount of the { 0 } kind: > > [torvalds@i7 linux]$ git grep 'struct.*= {[:space:]*0[:space:]*}' | wc > 616 3722 50034 Happily, in a x86-64 defconfig + allyesconfig, there is only 120 "Using plain integer as NULL pointer" warnings and not all of them are because of this { 0 }. But this make me wonder ... I'm all for strict typing, it's in general a precious help, but for this "Using plain integer as NULL pointer" warning: 1) the problem of using 0 (an int) in a variadic function call expecting a pointer (possibly larger than an int) is well known but is there any other problem of using 0 instead of NULL? 2) when the warning is issued it is known that a pointer is expected so a size problem like in 1) is not possible. So isn't this a case of a 'bad warning'? Maybe sarse should relax this warning, maybe only in (compound) initializer? [issuing a warning when passing 0 to a variadic function should address problem 1) but would probably create a lot of false warnings too]. -- Luc