From owner-freebsd-current@FreeBSD.ORG Mon Feb 2 19:58:15 2009 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6F7E1065693 for ; Mon, 2 Feb 2009 19:58:15 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from pele.citylink.co.nz (pele.citylink.co.nz [202.8.44.226]) by mx1.freebsd.org (Postfix) with ESMTP id 9443E8FC14 for ; Mon, 2 Feb 2009 19:58:15 +0000 (UTC) (envelope-from thompsa@FreeBSD.org) Received: from localhost (localhost [127.0.0.1]) by pele.citylink.co.nz (Postfix) with ESMTP id A7376FF81; Tue, 3 Feb 2009 08:58:14 +1300 (NZDT) X-Virus-Scanned: Debian amavisd-new at citylink.co.nz Received: from pele.citylink.co.nz ([127.0.0.1]) by localhost (pele.citylink.co.nz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3YS3keBxSgwB; Tue, 3 Feb 2009 08:58:10 +1300 (NZDT) Received: from citylink.fud.org.nz (unknown [202.8.44.45]) by pele.citylink.co.nz (Postfix) with ESMTP; Tue, 3 Feb 2009 08:58:10 +1300 (NZDT) Received: by citylink.fud.org.nz (Postfix, from userid 1001) id EBF561142A; Tue, 3 Feb 2009 08:58:09 +1300 (NZDT) Date: Mon, 2 Feb 2009 11:58:09 -0800 From: Andrew Thompson To: Christoph Mallon Message-ID: <20090202195809.GA54528@citylink.fud.org.nz> References: <49874CA8.5090605@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <49874CA8.5090605@gmx.de> User-Agent: Mutt/1.5.17 (2007-11-01) Cc: FreeBSD Hackers , FreeBSD Current Subject: Re: write-only variables in src/sys/ - possible bugs X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 19:58:16 -0000 On Mon, Feb 02, 2009 at 08:42:32PM +0100, Christoph Mallon wrote: > Hi, > > I compiled a list of all local variables in src/sys/ (r188000), which are > only written to, but never read. This is more than the GCC warning, which > only complains about variables, which are only declared (and maybe > initialised) and not used otherwise. In contrast this list contains > variables with the following usage pattern: > > int w = 42; // GCC warns about this ... > int x; // ... but not this > x = 23; > x++; > return 0; > > The list contains about 700 entries. About three dozen concern variables > named 'error'. Here's one *example* from the list: > > sys/dev/kbdmux/kbdmux.c:1304 > > In the function kbdmux_modevent() the variable 'error' is assigned values > eight times, but at the end of the function there is just a return 0; and > the variable is never read. Probably the value should be returned. > > You can find the list here: > http://tron.homeunix.org/unread_variables.log > > The list was generated by cparser, a C99 compiler, which uses libFIRM for > optimisation and code generation (lang/cparser in the ports). This is helpful, my only nit would be to run it through sort. :) Andrew