httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject -Wsign-compare
Date Mon, 22 Sep 1997 20:21:32 GMT
If someone is keen, it'd be interesting to see how many thousands of
warnings we get from -Wall on an egcs snapshot
<http://www.cygnus.com/egcs/>. 

Dean

---------- Forwarded message ----------
Date: Mon, 22 Sep 1997 16:57:22 +0200 (MET DST)
From: Thomas Koenig <ig25@mvmap66.ciw.uni-karlsruhe.de>
Reply-To: Thomas König <Thomas.Koenig@ciw.uni-karlsruhe.de>
To: linux-kernel@vger.rutgers.edu
Subject: Style question: comparison between signed and unsigned?

The current egcs snapshot includes -Wsign-compare in -Wall, which
warns about unexpected cases like

    int n;

    n = some_func();
    if (n > sizeof(int)) {
	/* This branch gets taken for n == -1 */
    }

and generates a ton of "warning: comparison between signed and unsigned"
messages when compiling the 2.0.30 kernel.

I'm sure that most of these don't matter, but I've been bitten once
by the bug above in Linux libc (the bug which caused the portmapper
to loop on -ECONNREFUSED), and I think it's quite possible that some
bugs may lurk in the kernel because of this.  I've had a look at some
of these cases, and I didn't feel sure that some cases could not
produce an error.

What do other people feel?  Should signed/unsigned conversions be
avoided in new code?  Should these be eliminated in 2.2?  Will patches
towards that goal be accepted if all they do is clean up error
messages?
-- 
Thomas Koenig, Thomas.Koenig@ciw.uni-karlsruhe.de, ig25@dkauni2.bitnet.
The joy of engineering is to find a straight line on a double
logarithmic diagram.



---------- Forwarded message ----------
Date: Mon, 22 Sep 1997 11:38:03 -0400
From: Bill Hawes <whawes@star.net>
To: Thomas =?ISO-8859-1?Q?K=F6nig ?= <Thomas.Koenig@ciw.uni-karlsruhe.de>
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: Style question: comparison between signed and unsigned?

Thomas Koenig wrote:
> What do other people feel?  Should signed/unsigned conversions be
> avoided in new code?  Should these be eliminated in 2.2?  Will patches
> towards that goal be accepted if all they do is clean up error
> messages?

I really dislike signed vs unsigned conversion bugs, and would certainly
prefer that new code avoid the situation.

But patches to fix warnings will need to be carefully considered, as
it's easy to accidentally introduce new problems.

Regards,
Bill



---------- Forwarded message ----------
Date: 22 Sep 1997 17:57:51 +0200
From: Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>
To: linux-kernel@vger.rutgers.edu
Subject: Re: Style question: comparison between signed and unsigned?

Thomas Koenig <ig25@mvmap66.ciw.uni-karlsruhe.de> writes:

> What do other people feel?  Should signed/unsigned conversions be
> avoided in new code?  Should these be eliminated in 2.2?  Will patches
> towards that goal be accepted if all they do is clean up error
> messages?

We've certainly eliminated several bugs by removing all these warnings
from glibc.  The benefit is also that you think twice about the types
of the variables.  Many people still unconditionally use `int's for
loop variables.  In many cases `unsigned int' is appropriate and it is
also faster in some cases on some platforms.  There are good reasons
for -Wall containing this option now.

-- Uli
---------------.      drepper@cygnus.com  ,-.   Rubensstrasse 5
Ulrich Drepper  \    ,-------------------'   \  76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper@gnu.ai.mit.edu  `------------------------



---------- Forwarded message ----------
Date: Mon, 22 Sep 1997 18:29:54 +0100 (BST)
From: Mark Cooke <mpc@star.sr.bham.ac.uk>
To: Thomas König <Thomas.Koenig@ciw.uni-karlsruhe.de>
Cc: linux-kernel@vger.rutgers.edu
Subject: Re: Style question: comparison between signed and unsigned?

On Mon, 22 Sep 1997, Thomas Koenig wrote:

> What do other people feel?  Should signed/unsigned conversions be
> avoided in new code?  Should these be eliminated in 2.2?  Will patches
> towards that goal be accepted if all they do is clean up error
> messages?

Signed/unsigned comparisions should (nearly) _always_ be avoided. It's a
symptom of inconsistancy/sloppy typedefs in the code. If it doesn't bite
you today, it might bite you tomorrow on a different architecture.

0.02c's worth

Mark

---------------------------------------------------------------------------
Mark Cooke                  The views expressed above are mine and are not
Systems Programmer          necessarily representative of university policy
University Of Birmingham    URL: http://www.sr.bham.ac.uk/~mpc/
---------------------------------------------------------------------------




---------- Forwarded message ----------
Date: 22 Sep 1997 13:09:39 -0500
From: Ulrich Drepper <drepper@ipd.info.uni-karlsruhe.de>
To: linux-kernel@vger.rutgers.edu
Subject: Re: Style question: comparison between signed and unsigned?

Thomas Koenig <ig25@mvmap66.ciw.uni-karlsruhe.de> writes:

> What do other people feel?  Should signed/unsigned conversions be
> avoided in new code?  Should these be eliminated in 2.2?  Will patches
> towards that goal be accepted if all they do is clean up error
> messages?

We've certainly eliminated several bugs by removing all these warnings
from glibc.  The benefit is also that you think twice about the types
of the variables.  Many people still unconditionally use `int's for
loop variables.  In many cases `unsigned int' is appropriate and it is
also faster in some cases on some platforms.  There are good reasons
for -Wall containing this option now.

-- Uli
---------------.      drepper@cygnus.com  ,-.   Rubensstrasse 5
Ulrich Drepper  \    ,-------------------'   \  76149 Karlsruhe/Germany
Cygnus Solutions `--' drepper@gnu.ai.mit.edu  `------------------------



Mime
View raw message