Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Feb 2016 11:57:14 -0800
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Conrad Meyer <cem@FreeBSD.org>
Cc:        Benjamin Kaduk <bjkfbsd@gmail.com>, Alan Somers <asomers@freebsd.org>, "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, Sergey Kandaurov <pluknet@gmail.com>, "src-committers@freebsd.org" <src-committers@freebsd.org>
Subject:   Re: svn commit: r295768 - head/usr.sbin/iostat
Message-ID:  <20160222195713.GC1945@FreeBSD.org>
In-Reply-To: <CAG6CVpUDWjSF6ht1hHKXp0PPh-H6zg51tace8=m0DEqdOrWGSA@mail.gmail.com>
References:  <201602182008.u1IK81vg092127@repo.freebsd.org> <CAE-mSO%2B7p=Equq81PPQjfZv1piPydBr4Mnk363CEs3w9EXRi9w@mail.gmail.com> <CAOtMX2hyZ=GFgp8F6t0dMDYF5FSPdoP9KdMU7V5rmscpaPUnsw@mail.gmail.com> <20160219230612.GR1945@FreeBSD.org> <CAJ5_RoCbWLUkwdRv4FeFVGpzCENooJbokH0SNXtiCeoRSeW%2BfQ@mail.gmail.com> <CAG6CVpUDWjSF6ht1hHKXp0PPh-H6zg51tace8=m0DEqdOrWGSA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Feb 19, 2016 at 04:50:40PM -0800, Conrad Meyer wrote:
C> > It is not quite as simple as this would make it sound.  The elements or
C> > members of an aggregate (e.g.) structure type are initialized as if it were
C> > an object of static storage duration (i.e., to zero) if the initializer list
C> > does not contain enough initializers for all members of the aggregate type,
C> > per item 21 of section 6.7.8 of n1256.pdf.  However, such initialization
C> > does not necessarily need to zero any padding bytes that are present, which
C> > may take unspecified values.  Personally, I think this particular clang
C> > warning can be too aggressive, especially for complex structs, but on the
C> > other hand given the indeterminateness of padding, bzero/memset are often a
C> > better choice anyway.
C> 
C> By definition, padding byte contents are unused.  There is no reason
C> their values matter one way or another, so why do we care about the
C> distinction between bzero and member zero initialization?

Well, one can run bcmp() or a hashing function over entire structure,
in that case contents of padding matter.

But I still don't want to see this warning in -Wall, since it kills
very useful C99 initializers.

The code, that runs bcmp() or hashes over structs, should take care, and
we shouldn't pessimize the entire build for its sake.

-- 
Totus tuus, Glebius.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160222195713.GC1945>