svn commit: r295768 - head/usr.sbin/iostat
Dimitry Andric
dim at FreeBSD.org
Fri Feb 19 23:23:53 UTC 2016
On 19 Feb 2016, at 16:49, Alan Somers <asomers at freebsd.org> wrote:
>
> On Fri, Feb 19, 2016 at 5:24 AM, Sergey Kandaurov <pluknet at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20160220/204b63ac/attachment.sig>
More information about the svn-src-all
mailing list