Date: Mon, 22 Feb 2016 23:57:43 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: David Chisnall <theraven@FreeBSD.org> Cc: Alan Somers <asomers@freebsd.org>, 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: <B8CAD299-A388-4437-9660-BFFBFDE89EB7@FreeBSD.org> In-Reply-To: <156A6796-D62B-4977-893B-E4E727578412@FreeBSD.org> References: <201602182008.u1IK81vg092127@repo.freebsd.org> <CAE-mSO%2B7p=Equq81PPQjfZv1piPydBr4Mnk363CEs3w9EXRi9w@mail.gmail.com> <CAOtMX2hyZ=GFgp8F6t0dMDYF5FSPdoP9KdMU7V5rmscpaPUnsw@mail.gmail.com> <83BB8467-4C40-4CF1-B394-1376C9D97FCF@FreeBSD.org> <156A6796-D62B-4977-893B-E4E727578412@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_D1F9D041-9575-40FF-B2B4-EE6F1905BBE9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 22 Feb 2016, at 10:56, David Chisnall <theraven@FreeBSD.org> wrote: >=20 > On 19 Feb 2016, at 23:23, Dimitry Andric <dim@FreeBSD.org> wrote: >>=20 >> 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. >=20 > The warning is annoying in many ways. You ought to be able to zero = initialise any struct with {0}, but clang objects if you do this and = requires every field to be filled in. This warning really shouldn=E2=80=99= t be enabled with -Wall, because it has too hight a false positive rate. It isn't, it is in -W (a.k.a -Wextra). But gcc also warns in this case. = E.g. if I use this example: struct foo { int i; int j; } bar[] =3D { { 42 }, { 43 } }; I get the following warnings from gcc -Wextra: $ gcc -Wextra -c initializers.c initializers.c:5:2: warning: missing initializer for field 'j' of = 'struct foo' [-Wmissing-field-initializers] { 42 }, ^ initializers.c:3:6: note: 'j' declared here int j; ^ initializers.c:6:2: warning: missing initializer for field 'j' of = 'struct foo' [-Wmissing-field-initializers] { 43 } ^ initializers.c:3:6: note: 'j' declared here int j; ^ Note that the warnings disappear if C99 initializers are used. -Dimitry --Apple-Mail=_D1F9D041-9575-40FF-B2B4-EE6F1905BBE9 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.29 iEYEARECAAYFAlbLknQACgkQsF6jCi4glqM5bQCghdAFmccwUc2pODSEp86SEgSw miUAoKK7lNvPr4ojr/PKxizoVorQy112 =+hXe -----END PGP SIGNATURE----- --Apple-Mail=_D1F9D041-9575-40FF-B2B4-EE6F1905BBE9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B8CAD299-A388-4437-9660-BFFBFDE89EB7>