From owner-svn-src-all@freebsd.org Fri Feb 19 15:49:45 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3DB6AAEB5A; Fri, 19 Feb 2016 15:49:44 +0000 (UTC) (envelope-from asomers@gmail.com) Received: from mail-ob0-x22e.google.com (mail-ob0-x22e.google.com [IPv6:2607:f8b0:4003:c01::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AA09E1F1B; Fri, 19 Feb 2016 15:49:44 +0000 (UTC) (envelope-from asomers@gmail.com) Received: by mail-ob0-x22e.google.com with SMTP id jq7so111309829obb.0; Fri, 19 Feb 2016 07:49:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=p5vA2r9iHZLlJt3fsoICx93EOlwBnH/0V/4oEEYIvE0=; b=hy6CgjfpYXywW+HyJJqZn7ZMr56hxRcNr8xmglCqdLDoFZyQvRMTFiZTdYKuMuIn5c 1mKu9IL1zf1fk5/0hchMTM98oiTTTJmXkNNI1B/l6cAAAPfwY01NYJ3gMjfBz1SqF6By Gxec9cvKOYi2rrin30JKuIWSZhuZB9ex9AWC5JkXUISKaEz5di+d/vG8h2w47DZgZvto Kk1yoGz1vSPUxtkzmQLuAnv26ckJnPLmGN/SuT5xZH7fA83moueXSKRtTGD36YhlT1r9 jcOqSJtQKK3FwRCjTn3Dfe/fSckCJDC9J8Y1aKxBNjzdxiDllBDfDKyrn5n2QJ8pyMKP uopA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=p5vA2r9iHZLlJt3fsoICx93EOlwBnH/0V/4oEEYIvE0=; b=Y25kqRijYVCIlT2Pv0eWcTNh+u7IJktrL4K1JCHViXi2oJzo1diEapdije53GuWwsm 3Y3KXkIkrbnFQmWoYk9aDeH7sEunjxqkBYXniaXln1lRI7xvN/k9cyKwaOiTgOcH3aSR VHbpEefuAyTybgiMaI+e4QxV36qKoBoy+7sMyDaiH/IvaX8Kqgq8pMUzcR5qU7AY4qgO MIVBNKvuDld4rECmSDGzcktf3EOUjymMgDj0qZ+Xdt0TPhMZDsv8XnVFmTj94QY8EvcS MSxlPUv7TjtnE/oqBPcQ3QwhEK2NIDwvnB4TRLRbByxHVNxgX8I/4Stkg8euXiXP2Xcy hpsQ== X-Gm-Message-State: AG10YOS2HHupNabANWsadAHvdkq2MVoVT4c09xkUxa0g2V6WSmN2zvobXmV+nfhfGAsdlxQ3ns/8JRfP4snCEQ== MIME-Version: 1.0 X-Received: by 10.60.67.34 with SMTP id k2mr12225431oet.67.1455896983931; Fri, 19 Feb 2016 07:49:43 -0800 (PST) Sender: asomers@gmail.com Received: by 10.202.78.83 with HTTP; Fri, 19 Feb 2016 07:49:43 -0800 (PST) In-Reply-To: References: <201602182008.u1IK81vg092127@repo.freebsd.org> Date: Fri, 19 Feb 2016 08:49:43 -0700 X-Google-Sender-Auth: RYSjAZxAgChiYPbgf6UW6qkZwPc Message-ID: Subject: Re: svn commit: r295768 - head/usr.sbin/iostat From: Alan Somers To: Sergey Kandaurov Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2016 15:49:45 -0000 On Fri, Feb 19, 2016 at 5:24 AM, Sergey Kandaurov wrote: > On 18 February 2016 at 23:08, Alan Somers wrote: >> Author: asomers >> Date: Thu Feb 18 20:08:01 2016 >> New Revision: 295768 >> URL: https://svnweb.freebsd.org/changeset/base/295768 >> >> Log: >> Fix compiler warnings in iostat > >> Modified: head/usr.sbin/iostat/iostat.c >> ============================================================================== >> --- head/usr.sbin/iostat/iostat.c Thu Feb 18 19:37:39 2016 (r295767) >> +++ head/usr.sbin/iostat/iostat.c Thu Feb 18 20:08:01 2016 (r295768) >> @@ -117,30 +117,34 @@ >> #include >> #include >> >> -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. > > Consider these two cases: > > : #include > : > : int main(void) { > : struct nlist namelist[2] = {{ .n_type = 0x42 }}; > : return sizeof(namelist); > : } > > (__TEXT,__text) section > _main: > 0000000000000000 pushq %rbp > 0000000000000001 movq %rsp, %rbp > 0000000000000004 leaq -0x30(%rbp), %rdx > 0000000000000008 movl $0x0, %eax > 000000000000000d movl $0x6, %ecx > 0000000000000012 movq %rdx, %rdi > 0000000000000015 rep > 0000000000000016 stosq > 0000000000000018 movb $0x42, -0x28(%rbp) > 000000000000001c movl $0x30, %eax > 0000000000000021 popq %rbp > 0000000000000022 retq > > rep stosq does zero 48 bytes, that is namelist[]. > > Or, if it is static. > > : #include > : > : int main(void) { > : static struct nlist namelist[2] = {{ .n_type = 0x42 }}; > : return sizeof(namelist); > : } > > (__DATA,__data) section > 0000000000000020 00 00 00 00 00 00 00 00 42 00 00 00 00 00 00 00 > 0000000000000030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > 0000000000000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 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. -Alan