From owner-freebsd-current@FreeBSD.ORG Mon Feb 2 20:47:25 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 440BD106568D for ; Mon, 2 Feb 2009 20:47:25 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by mx1.freebsd.org (Postfix) with ESMTP id 9D6068FC1D for ; Mon, 2 Feb 2009 20:47:24 +0000 (UTC) (envelope-from max@love2party.net) Received: from vampire.homelinux.org (dslb-088-064-183-042.pools.arcor-ip.net [88.64.183.42]) by mrelayeu.kundenserver.de (node=mrelayeu3) with ESMTP (Nemesis) id 0MKxQS-1LU5hT2BCC-0005vg; Mon, 02 Feb 2009 21:47:23 +0100 Received: (qmail 83058 invoked from network); 2 Feb 2009 20:47:23 -0000 Received: from fbsd8.laiers.local (192.168.4.200) by laiers.local with SMTP; 2 Feb 2009 20:47:23 -0000 From: Max Laier Organization: FreeBSD To: freebsd-hackers@freebsd.org Date: Mon, 2 Feb 2009 21:47:22 +0100 User-Agent: KMail/1.10.4 (FreeBSD/8.0-CURRENT; KDE/4.1.4; i386; ; ) References: <49874CA8.5090605@gmx.de> In-Reply-To: <49874CA8.5090605@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902022147.22862.max@love2party.net> X-Provags-ID: V01U2FsdGVkX1+rBp1ed6OD7/5rDeIFVxbTYt2rFjRocaWR6Yi iGSUkSrkkXIo4NwprsGJt4HkD5S0IzlCXErGhTjWUVHKMHNh1g JAGp5rKqpTUtTsoAfCkrQ== Cc: Christoph Mallon , 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 20:47:32 -0000 On Monday 02 February 2009 20:42:32 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). > > > A small disclaimer: There might be some false positives due to errors > which are caused by HEAD sources in combination with my installed 7.x > headers plus a hacked up build process. Also some warnings are the > result from variables, which are only used in debug macros, so td = > curthread; KASSERT(td != NULL); provokes a warning (I consider this bad > style). Nonetheless the number of false positives should be low. If > there is interest, then I can compile a "proper" list. Are you interested in false positive reports? If so, I think sys/contrib/pf/net/pf.c:2931 is one. Seems cparser is confused by the union in struct assignment, maybe? Or it suffers from the similar issue with switch/case-statements as gcc. saddr is read from in all but the default case. -- /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News