Web lists-archives.com

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




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