From: Paul Jackson <pj@sgi.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: akpm@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] disable gcc warnings of sign/unsigned comparison
Date: Thu, 1 Jan 2004 15:15:16 -0800 [thread overview]
Message-ID: <20040101151516.236cb610.pj@sgi.com> (raw)
In-Reply-To: <1072977297.1399.14.camel@nidelv.trondhjem.org>
> How about therefore instead sending him a patch which fixes the actual
> code that is causing these warnings to be generated?
If such a patch generates more crap code (hence, sooner or later,
bugs) than it fixes, that's the wrong choice.
Right now, compiling a 2.6.0-mm1 (what I had handy) with the 3.3 gcc on
my Pentium system for arch i386 generates 1386 signed and unsigned
warnings, of the two kinds:
warning: signed and unsigned type in conditional expression
warning: comparison between signed and unsigned
A patch that resolved these 1386 warnings would (1) generate more
crap than it cleaned up, (2) immediately result in adding more bugs
than removed, and (3) due to the crap level rising, generate more
bugs long term than it avoided.
If Andrew accepted a patch from me that messed with all 1386 code
locations (and that's just for arch = i386) generating these warnings,
then I'd recommend that he be relieved of 2.6 kernel duties for
incompetence. (Have no fear, Andrew - I would not make such a patch, I
trust you would not accept it, and Linus would not listen to my
recommendation).
> (see, for instance, the somewhat "unconventional" Linux min() and
> max() macros)
There's more going on in min and max than just checking for signed
versus unsigned comparison. Other type mismatches are seen as well.
==
Let me step back a minute. There is a useful lesson here.
The single most important technical key to the long term health of Linux
is "good code" - can the competent kernel hacker read and understand and
successfully modify the code.
This probably even outweighs the current 'bug' count, and certainly
outweighs the count of warnings from the compiler.
If a big chunk of intrusive code looked like it had been written in
Richard Gooch's idiosyncratic style, and then run through the Nvidia
obfuscator, then even if it was 'perfect' (mathematically proven to have
zero bugs and zero gcc warnings), we would not want it.
Normally I would agree with your sentiment - change the code to remove
the warning, even if I have to do something a little bit ugly or silly.
Many a time in my 25 years of serious coding, I have done just that.
But there's always a tradeoff here - the probability of a bug due to
an ignored warning versus the probability of a bug due to the slight
increase in human confusion due to the extra code crap.
If a warning is not seen that often, and has a half decent chance of
catching a real bug when it does fire, and doesn't result in that much
extra code crap when 'worked around', then on net, the warning is worth
dealing with, even at the occassional expense of a little bit of silly
code crap.
But if a warning is seen many times, very few of which catch bugs, and
forces wide spread instances of unnatural coding acts to work around,
then on net, it hurts more than it helps.
What we have here, with this warning, is one of the clearest examples
of this later case that I've seen.
Linus is right - it's a bad warning.
==
There are only two possible resolutions that I can imagine myself
endorsing here. Either we turn off the warning (-Wno-sign-compare, as
in my patch) or more recent versions of gcc don't complain nearly as
much, making it a mute point.
Have you knowledge that more recent versions of gcc don't complain
nearly as much of this warning? If so, I will upgrade my gcc and shut
up.
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.650.933.1373
next prev parent reply other threads:[~2004-01-01 23:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-01 12:33 [PATCH] disable gcc warnings of sign/unsigned comparison Paul Jackson
2004-01-01 17:14 ` Trond Myklebust
2004-01-01 23:15 ` Paul Jackson [this message]
2004-01-01 23:33 ` Andrew Morton
2004-01-02 0:08 ` Tomas Szepe
2004-01-02 3:20 ` Paul Jackson
2004-01-02 0:46 ` Trond Myklebust
2004-01-02 0:59 ` Tomas Szepe
2004-01-02 1:31 ` Paul Jackson
2004-01-02 3:05 ` Paul Jackson
[not found] <19ahq-7Rg-11@gated-at.bofh.it>
[not found] ` <19eEs-5lC-15@gated-at.bofh.it>
[not found] ` <19kgS-4HT-19@gated-at.bofh.it>
2004-01-02 1:33 ` Andi Kleen
2004-01-02 3:07 ` Paul Jackson
2004-01-05 1:41 ` Adrian Bunk
2004-01-05 13:16 ` Paul Jackson
2004-03-29 15:44 ` Paul Jackson
2004-03-29 15:43 ` Adrian Bunk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040101151516.236cb610.pj@sgi.com \
--to=pj@sgi.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox