From owner-svn-src-head@FreeBSD.ORG Sun Aug 23 15:54:54 2009 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 713381065691; Sun, 23 Aug 2009 15:54:54 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id 062888FC1D; Sun, 23 Aug 2009 15:54:53 +0000 (UTC) Received: from c122-106-152-1.carlnfd1.nsw.optusnet.com.au (c122-106-152-1.carlnfd1.nsw.optusnet.com.au [122.106.152.1]) by mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id n7NFshUE004184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Aug 2009 01:54:44 +1000 Date: Mon, 24 Aug 2009 01:54:43 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Christoph Mallon In-Reply-To: <4A9155BA.9020808@gmx.de> Message-ID: <20090824013656.M38813@delplex.bde.org> References: <200908230759.n7N7xS6g051165@svn.freebsd.org> <20090823080940.GT1292@hoeg.nl> <20090823230300.Q38728@delplex.bde.org> <4A9155BA.9020808@gmx.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Ed Schouten , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, Bruce Evans , svn-src-head@FreeBSD.org, Julian Elischer Subject: Re: svn commit: r196451 - head/sys/netinet/ipfw X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 23 Aug 2009 15:54:54 -0000 On Sun, 23 Aug 2009, Christoph Mallon wrote: > Bruce Evans schrieb: >> % */ >> % int >> % ipfw_init(void) >> % { >> % int error = 0; >> >> This variable is not really used. >> >> Initialization in declaration. This mainly obfuscates the non-use of the >> variable. > > Rather the opposite is true: > > void f(void) > { > int error = 0; // GCC warns that error is unused > } > > void g(void) > { > int error; > error = 0; // GCC is silent > } Interesting. A bug in gcc. Even the primitive lint(1) in FreeBSD warns about both (it says "set but not used"; if the variable is not even set, then it says "unused"). > In this case it does not help, because error is used. But an assignment > halfway down the function definitely would not improve the situation. The assignment should be just before the first use of the variable (if the first use is conditional, this may be impossible, but then an initialization at the start of the function would increase the obfuscation). In this case, the first use is in the return statement and it would then be obvious to everyone except the compiler that both the variable and its initialization are bogus: error = 0; return (error); A non-KNF style would put the declaration next to the use. Then the bogusness would be even more obvious: #if __STDC_VERSION__ < 199901 { #endif int error; error = 0; return (error); #if __STDC_VERSION__ < 199901 } #endif Bruce