Date: Sat, 20 Feb 2016 00:23:40 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Alan Somers <asomers@freebsd.org> Cc: Sergey Kandaurov <pluknet@gmail.com>, "src-committers@freebsd.org" <src-committers@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org> Subject: Re: svn commit: r295768 - head/usr.sbin/iostat Message-ID: <83BB8467-4C40-4CF1-B394-1376C9D97FCF@FreeBSD.org> In-Reply-To: <CAOtMX2hyZ=GFgp8F6t0dMDYF5FSPdoP9KdMU7V5rmscpaPUnsw@mail.gmail.com> References: <201602182008.u1IK81vg092127@repo.freebsd.org> <CAE-mSO%2B7p=Equq81PPQjfZv1piPydBr4Mnk363CEs3w9EXRi9w@mail.gmail.com> <CAOtMX2hyZ=GFgp8F6t0dMDYF5FSPdoP9KdMU7V5rmscpaPUnsw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 19 Feb 2016, at 16:49, Alan Somers <asomers@freebsd.org> wrote:
>
> On Fri, Feb 19, 2016 at 5:24 AM, Sergey Kandaurov <pluknet@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 #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.29
iEYEARECAAYFAlbHpAUACgkQsF6jCi4glqMxlQCg/fTaWwEfvIldNSVMJDEjxMbV
xD0AoI7Hez0QV3G6p9UhX8FsRzU/eYZJ
=fJ6B
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?83BB8467-4C40-4CF1-B394-1376C9D97FCF>
