Date: Mon, 7 Dec 1998 03:52:14 +1100 From: Bruce Evans <bde@zeta.org.au> To: archie@whistle.com, cvs-committers@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: getting to -Wunused Message-ID: <199812061652.DAA22562@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>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 <sys/cdefs.h>, 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812061652.DAA22562>