From owner-cvs-all Sat Dec 5 16:33:31 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA01047 for cvs-all-outgoing; Sat, 5 Dec 1998 16:33:31 -0800 (PST) (envelope-from owner-cvs-all@FreeBSD.ORG) Received: from whistle.com (s205m131.whistle.com [207.76.205.131]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA01042; Sat, 5 Dec 1998 16:33:30 -0800 (PST) (envelope-from archie@whistle.com) Received: (from smap@localhost) by whistle.com (8.7.5/8.6.12) id QAA11755; Sat, 5 Dec 1998 16:32:49 -0800 (PST) Received: from bubba.whistle.com( 207.76.205.7) by whistle.com via smap (V2.0) id xma011753; Sat, 5 Dec 98 16:32:44 -0800 Received: (from archie@localhost) by bubba.whistle.com (8.8.7/8.6.12) id QAA01400; Sat, 5 Dec 1998 16:32:44 -0800 (PST) From: Archie Cobbs Message-Id: <199812060032.QAA01400@bubba.whistle.com> Subject: getting to -Wunused To: freebsd-hackers@FreeBSD.ORG, cvs-committers@FreeBSD.ORG Date: Sat, 5 Dec 1998 16:32:44 -0800 (PST) X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk Hi, It looks like the next kernel compilation -W flag to be slayed is the "-Wunused" flag (see bsd.kern.mk).. right now, compiling LINT with this flag yeilds about 350 unused variable or function warnings. These warnings break down into several cases: (a) Variables (and a couple of goto labels) that are defined but simply never referenced within their scope. (b) Variables and static functions that are defined, but only referenced conditionally (ie, #ifdef some macro) within their scope (c) Static functions that are declared but never defined (ie, static function prototype at the top of the file but no corresponding function anywhere in the file). (d) Static functions that are declared and defined, but never used: (i) Some of these are defined #ifdef DDB, and are clearly meant for debugging purposes (they're not used, but they're handy to call from the debugger to print out stuff, etc). These are "legitimate" unused functions. (ii) The rest seem to be left-over cruft that should be removed (but this job is best left to the maintainer of that code). My proposal is to tackle these warnings in several steps.. Step #1. The "easy" stuff first: - Fix all (a) cases by removing the declaration. - Fix all (b) cases by making the declaration subject to the same #ifdef (or commenting out) as the use (sometimes this means relocating the declaration to an inner block). - Fix all (c) cases by removing the useless declaration. NOTE: this does *not* include variables initialized with a value that's the result of some function call (which could have side effects), nor variables meant to server as marks in the data segment, such as sys/ufs/mfs/mfs_vfsops.c:end_mfs_root. Step #2. Add "__attribute__ ((unused))" to all cases of (d)(i), that is, obviously legitimate unused functions (I count only 2 so far). Step #3. Turn on -Wunused in bsd.kern.mk so everybody can participate :-) Step #4. Let any remaining warnings be handled by their respective maintainers. Note that Steps #1 and #2 will *not* eliminate all the unused variable warnings, because I can't do a kernel compile with every possible permutation of kernel options.. but it should get most of them. Step #2 (later!) will be a very small patch. I plan to commit patches for step #1 in a couple of days if there's no fears/complaints... these are available for review here: ftp://ftp.whistle.com/pub/archie/misc/PATCH.unused There are 112 files affected. COMMITTERS: if you are afraid of something getting screwed up by Step #1, please review the patch for the file(s) you're interested in. Thanks, -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message