Re: [PATCH 00/52] fix some -Wmissing-field-initializer warnings

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

 



Hi Ramsay,

I had a brief look at the series. IMO, it is a mistake to appease
-Wmissing-field-initializer.

We have two sorts of initializers:

 - zero initializers: they just want to null out every field,
   like CHILD_PROCESS_INIT and ad-hoc initializers of structs
   such as xpparam_t pp = { 0 }; in range-diff.c

 - value initializers are always macros, such as STRING_LIST_INIT_DUP
   and the OPT_* family.

I am strongly against forcing zero initializers to write down a value
for every field. It is much more preferable to depend on that the
compiler does the right thing with them. -Wmissing-field-initializer
would provide guidance in the wrong direction. A zero initializer looks
like this: = { 0 }; and nothing else.

(And for this reason, I also think it is wrong to change 0 to NULL in
initializers to appease sparse's "zero used as pointer value" warning.
Let the compiler do the right thing.)

Value initializers are a different matter. The changes you have prepared
around struct option initializers are good, IMO. Whether or not you add
trailing zeros to the macros makes no difference for the users of the
macros.

-- Hannes



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux