Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jan 1999 20:41:55 +0200 (SAT)
From:      Robert Nordier <rnordier@nordier.com>
To:        gelderen@mediaport.org (Jeroen C. van Gelderen)
Cc:        rnordier@nordier.com, peter@netplex.com.au, fenner@parc.xerox.com, bde@zeta.org.au, cvs-committers@FreeBSD.ORG
Subject:   Re: -Werror
Message-ID:  <199901201841.UAA06207@ceia.nordier.com>
In-Reply-To: <031a01be4495$52293240$0d79eb0a@deskfix.local> from "Jeroen C. van Gelderen" at "Jan 20, 99 05:52:52 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
Jeroen C. van Gelderen wrote:
> From: Robert Nordier <rnordier@nordier.com>
> >For example, compiled with -Wall, the code fragment
> >
> >    if (x = y)
> >     x = z + 1 & 7;
> >
> >causes two warnings
> >
> >    suggest parentheses around assignment used as truth value
> >    suggest parentheses around + or - in operand of &
> >
> >but rewriting to eliminate the errors would violate a style(9)
> >guideline (unnecessary parentheses).
> 
> Maybe you should consider updating style(9). A lot of companies would
> consider parentheses in the last line absolutely neccessary. Chances are
> that requiring parentheses in the first line will catch a few errors.
> Chances that extra parentheses in the first line will *cause* errors are
> quite small. Especially when you rewrite the line like:
>  if( (x = y) != 0 )
> which *IMHO* is the only correct way.

I guess there's probably something to be said for any particular way
of doing it, assuming there was some thought behind the original
style(9) recommendation.  Though your point that additional
parentheses are safer on the whole seems reasonable.

> >There's an awful lot of BSD
> >code like this, that could cause huge {Net,Open}BSD diffs if
> >rewritten.
> 
> Hmm, but I thought the other BSD(s?) used -Werror? That would reverse your
> argument ;)

Actually, my argument is only that consistency is important, and
that proper guidelines, codifying *existing* practice (except where
there is good reason to change) should exist.  Although style(9)
is useful, it is outdated in certain respects, and it doesn't
really cover all the bases.

Bruce spends a fair amount of time committing fixes for "style bugs"
and pointing these out in submissions; and the choices he makes
probably constitute the de facto FreeBSD style.  But I'd suspect
that, to many or most people, his decisions are, to some extent,
inscrutable.  This situation adds to the whole bde mystique, but it
probably wastes Bruce's time (since style is really a trivial issue),
and it doesn't help folks who would prefer to just DTRT themselves.

> 
> >So (to give just one example) if -Werror if used, -Wall becomes
> >problematic.  And so -Werror may result in useful warnings getting
> >turned off rather than on.
> 
> Fix style(9) and that problem goes away.

I think if we fix style(9) properly, and then make the many code
changes that will permit -Werror to work, the whole issue may
go away.  This doesn't force -Werror as the default, but will
at least allow it as an option.

-- 
Robert Nordier

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199901201841.UAA06207>