On 19 Feb 2016, at 16:49, Alan Somers <asom...@freebsd.org> wrote:
> 
> On Fri, Feb 19, 2016 at 5:24 AM, Sergey Kandaurov <pluk...@gmail.com> wrote:
...
>>> -struct nlist namelist[] = {
>>> +static struct nlist namelist[] = {
>>> #define X_TTY_NIN      0
>>> -       { "_tty_nin" },
>>> +       { .n_name = "_tty_nin",
>>> +         .n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 },
>>> [...]
>> 
>> You unlikely need this excessive explicit zeroization.
>> In this case it is implicitly prezeroed.
...
> Yeah, it was being implicitly zeroized before.  But Clang complained
> about the structures being only partially initialized.  Since the
> whole point of my commit was to increase the WARNS level, I explicitly
> zeroed the zero fields to silence Clang.

You got this warning, most likely:

usr.sbin/iostat/iostat.c:122:15: error: missing field 'n_type' initializer 
[-Werror,-Wmissing-field-initializers]
        { "_tty_nin" },
                     ^

This warning is only produced when you use -Wall -W, and then initialize
structs partially, i.e. you initialize some fields but not others.  I
think this is a quite reasonable warning for a high warning level.

On the other hand, if this kind of construct is used throughout the
tree, and it is not seen as a big problem, we can simply silence this
particular warning using -Wno-missing-field -initializers.  There is
already quite a list of warnings which are suppressed by default, even
at WARNS=6, namely:

-Wno-empty-body
-Wno-format-y2k
-Wno-pointer-sign
-Wno-string-plus-int
-Wno-unused-const-variable
-Wno-unused-parameter

-Dimitry

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to