This is the mail archive of the gdb-patches@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]

-W* rules for engagement?


(The obvious follow on from PARAMS :-)

How do people think we should attack this?  I'm talking both from a
logistic point of view of how should it be done and a philosophical view
of position (w.r.t. warnings) should be taken.

I can think of two extreme viewpoints:

	o	fixing warnings is a waste of time.
		we've better things to do and besides
		we don't make mistakes.  Go away.

	o	GDB shall compile with
		  -Wall -Wa-few-extras -Werror
		and emit no warnings.  Drop
		everything and fix all warnings
		now.  Add something to CVS so that
		it doesn't accept code containing
		warnings.

The obvious flaw with the first (and yet highly convincing argument) is
that people do make mistakes.  A second and more significant problem is
that code that contains ``warnings'' is, to a new developer, in an
unknown state - was that if assignment ``if (x = y)'' intentional?. 
While not much of an problem in a small project with a single developer,
it is a very big issue with a large long lived project with many
developers (such as GDB).  Being able to make a change to a file knowing
that before/after it should contain no warnings is a real confidence
booster to a developer.  The reason I spent a significant amount of time
last year expunging key warnings was so that I could, with a certain
degree of confidence, make sweeping (but mechanical) changes across many
files.

The second proposal just needs a reality check.  While some warning
checks (e.g. -Wformat) have a relatively small over head and a very
significant return others such as -Wunused-parameters (yes, GCC 3.0 does
accept it!), I would argue, are of marginal benefit.  In selecting
warnings I think we need to be careful to choose those that avoid lots
of false negatives.  Further, given the vaguarities of operating systems
it is also often the case that zero warnings are physically impossible.


So what then?  I'd like to suggest we pad out the current list of
warnings:

  -Wimplicit -Wreturn-type -Wcomment -Wformat -Wparentheses
-Wpointer-arith

with a few additional key warnings such as -Wuninitialized
-Wmissing-prototypes (any others?) and then try to get these down to
zero so that -Werror can be used on this contracted list.  Beyond that,
people, can pursue things at their leisure.

How to approach this? I'm easy.  I am wary of fix warning a-thons and
the like.  Often fixing a warning involves a careful re-examination of
the code.  If someone wants to take it on, I'm again easy.

	Andrew

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