svn commit: r295768 - head/usr.sbin/iostat

Benjamin Kaduk bjkfbsd at gmail.com
Fri Feb 19 23:14:48 UTC 2016


On Fri, Feb 19, 2016 at 5:06 PM, Gleb Smirnoff <glebius at freebsd.org> wrote:

> On Fri, Feb 19, 2016 at 08:49:43AM -0700, Alan Somers wrote:
> A> On Fri, Feb 19, 2016 at 5:24 AM, Sergey Kandaurov <pluknet at gmail.com>
> wrote:
> A> Yeah, it was being implicitly zeroized before.  But Clang complained
> A> about the structures being only partially initialized.  Since the
> A> whole point of my commit was to increase the WARNS level, I explicitly
> A> zeroed the zero fields to silence Clang.
>
> Isn't zero filling part of the standard? I don't see why lack of
> explicit zeroing is a warning? Looks a false warning to me.
>

It is not quite as simple as this would make it sound.  The elements or
members of an aggregate (e.g.) structure type are initialized as if it were
an object of static storage duration (i.e., to zero) if the initializer
list does not contain enough initializers for all members of the aggregate
type, per item 21 of section 6.7.8 of n1256.pdf.  However, such
initialization does not necessarily need to zero any padding bytes that are
present, which may take unspecified values.  Personally, I think this
particular clang warning can be too aggressive, especially for complex
structs, but on the other hand given the indeterminateness of padding,
bzero/memset are often a better choice anyway.

-Ben


More information about the svn-src-head mailing list