This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

unused parameter warnings



I think the warnings about unused parameters are unnecessary,
unhelpful, and obstructive.  I think we should add -Wno-unused to our
warning flag list, to turn off those warnings.


Here's why I think the warnings are unneccessary:

In programs that use a lot of pointers to functions, the code which
makes those indirect calls doesn't know which particular function will
be invoked, so the argument lists are often more general than some
callees will need.

One example of this is in Insight: gdb/gdbtk/generic/gdbtk-cmds.c, for
example, defines a lot of new Tcl commands.  Every Tcl command is
passed a pointer to the Tcl interpreter structure and a "ClientData"
pointer, whether it needs it or not.

There are many similar situations in GDB: the target vector, the
gdbarch structure, the symbol file functions, the core file handlers,
and probably others.  All are cases where we provide specialized
functions implementing generalized interfaces.

This is a perfectly healthy design pattern, reflecting a natural
relationship between generic and specialized code.

So, in the case of GDB, the condition reported by this warning occurs
frequently in code which is correct, and perhaps even well-designed.


Here's why I think they are unhelpful:

When gdbtk-cmds.c compiles cleanly, I get 113 "parameter unused"
warnings.  There's simply no way on earth I'm going to check all 113
warnings to make sure they're benign.  Once I've established the
pattern, I ignore them.  You do too.

Thus, even if there were a parameter which was incorrectly being
ignored, this warning is unlikely to help us find it.


Here's why I think they are obstructive:

Actually, in total, I get 114 warnings when I compile gdbtk-cmds.c.
The extra warning is a "comparison between signed and unsigned".
That's a warning which may or may not indicate something worth
worrying about.

But I only noticed this because I was going over the compilation
output carefully in order to write this message.  In other
circumstances, I would have paged quickly past the four pages of
warnings, and not noticed it.

Thus, these warnings lead us to overlook signs of possibly genuine
problems.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]