From owner-freebsd-hackers Sun Dec 6 08:52:28 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id IAA14395 for freebsd-hackers-outgoing; Sun, 6 Dec 1998 08:52:28 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from godzilla.zeta.org.au ([203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id IAA14387; Sun, 6 Dec 1998 08:52:24 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id DAA22562; Mon, 7 Dec 1998 03:52:14 +1100 Date: Mon, 7 Dec 1998 03:52:14 +1100 From: Bruce Evans Message-Id: <199812061652.DAA22562@godzilla.zeta.org.au> To: archie@whistle.com, cvs-committers@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: getting to -Wunused Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >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. Only 266 now (after lprintf fixes?). Actually, plain -W is next. Among other warnings, it gives an additional 2763 warnings for unused function parameters. (This is documented in gcc.info but not in gcc.1.) Most of these are not bogons and can't be fixed nicely, so the bogons reported by -Wunused should be fixed first. > (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. No, these are illegitimate. The should be attached to the ddb command table so that they are both used and easier to use. Use the DDB_COMMAND and DDB_SHOW_COMMAND macros for this. Don't break the warning by decaring the functions as __unused. (Bug: these macros usually add dummy args that make it harder to call the functions directly. Direct calls are still useful, at least from gdb.) > Step #2. Add "__attribute__ ((unused))" to all cases of (d)(i), that is, > obviously legitimate unused functions (I count only 2 so far). __attribute__(()) should not be used outside of , especially when there is already a suitable macro there, namely `__unused'. `__attribute__ ((unused))' has 1 style bug and 1 real bug. >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. You should check for variables that are used in ifdefed code and ifdef the variables. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message