From owner-svn-src-head@freebsd.org Fri Feb 19 12:24:17 2016 Return-Path: Delivered-To: svn-src-head@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 B9697AADDCF; Fri, 19 Feb 2016 12:24:17 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com [IPv6:2a00:1450:400c:c09::232]) (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 67F03176A; Fri, 19 Feb 2016 12:24:17 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: by mail-wm0-x232.google.com with SMTP id g62so73583278wme.1; Fri, 19 Feb 2016 04:24:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=UelDHx+65EArP6GXV4FCTWH/gGuhlUC9YEujELVuOkM=; b=S8Rxi50XZ/Ho143zVVdzCPibpUr31A/sa0NmnhuOcCc6lLIOM30m/xGdg1kzmZNYmr 0yVfizBgBlb5zmdBzNzAN0L/9S+GIuA7Cmb3bZbVvNCL35jjv3BOv62uVNHZuwQJxUHU r77IOZ/NNjpdNKUHlrTiSOGqkhoARVC9gS0T17G67wSaSpch9ZmP55+HgAooTiSkvL9D 4O5VFrZgtPPcR/vcjh8nucB3Xh6iLbA+avchpd2S4nrF7Z2SYUYcnIWAQA5G9o/PsmdC xluMZB/NtXMFTzNVncTv4seOgKkgRIniJl4dU8ziw57/eRU768TntS2lqK/juDZbGQgb xb2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=UelDHx+65EArP6GXV4FCTWH/gGuhlUC9YEujELVuOkM=; b=GtmnM72yalnc3ReUNkE+cxCeryq29ttlYeVXvU/iFiDKsM4BUle8zDCURtNa1SzhiZ 9M5XAOIDzQ9TX+CSvjw/CWZCH+Lc/eaBIkoIKJanXsu82fR2/5uAuQgdOCmOBzGXQNaK mvUuyqArKP1GX8/uqn8250vOrk2gRsOu7HU8357Aw6xf+46jUPvDXGHGaCciiWUa7dPX 00PEmoVr1ZuJKMbqVbt36eIZezeU5PjBYUEj2owV1v8zyi64ZaOhAfwhzA87EyZyZG2a l3KmYp+EqY33B5iU7lKW6QyOoLf83aM8EGG/3mTkEypR1Anqt1xUijkjyQQee/scpSqg EVJA== X-Gm-Message-State: AG10YOS4aAA0gPVTxFjlLfaD67zrcl2XoGsFCV40pEQXO0vRfcRetqqAKaWT/8TG+PW6tQIb4ICBGwK6OZfM/g== MIME-Version: 1.0 X-Received: by 10.194.63.202 with SMTP id i10mr12889819wjs.118.1455884655895; Fri, 19 Feb 2016 04:24:15 -0800 (PST) Received: by 10.194.234.130 with HTTP; Fri, 19 Feb 2016 04:24:15 -0800 (PST) In-Reply-To: <201602182008.u1IK81vg092127@repo.freebsd.org> References: <201602182008.u1IK81vg092127@repo.freebsd.org> Date: Fri, 19 Feb 2016 15:24:15 +0300 Message-ID: Subject: Re: svn commit: r295768 - head/usr.sbin/iostat From: Sergey Kandaurov To: Alan Somers 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-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2016 12:24:17 -0000 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 -- wbr, pluknet