mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Jesper Juhl <juhl-lkml@dif.dk>
Cc: Matthew Wilcox <matthew@wil.cx>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Remove pointless <0 comparison for unsigned variable in fs/fcntl.c
Date: Tue, 23 Nov 2004 10:03:55 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0411230958260.20993@ppc970.osdl.org> (raw)
In-Reply-To: <41A30612.2040700@dif.dk>



On Tue, 23 Nov 2004, Jesper Juhl wrote:
>
> Linus, would you accept patches like this?

No, please don't.

The warning is sometimes useful, but when it comes to a construct like

	if (a < 0 || a > X)

the fact that "a" is unsigned does not make the construct silly. First 
off, it's (a) very readable and (b) the type of "a" may not be immediately 
obvious if it's a user typedef, for example. 

In fact, the type of "a" might depend on the architecture, or even 
compiler flags. Think about "char" - which may or may not be signed 
depending on ABI and things like -funsigned-char.

In other places, it's not "unsigned" that is the problem, but the fact 
that the range of a type is smaller on one architecture than another. So 
you might have

	inf fn(pid_t a)
	{
		if (a > 0xffff)
			...
	}

which might warn on an architecture where "pid_t" is just sixteen bits 
wide. Does that make the code wrong? Hell no.

IOW, a lot of the gcc warnings are just not valid, and trying to shut gcc 
up about them can break (and _has_ broken) code that was correct before.

> I probably won't be able to properly evaluate/review *all* the instances 
> of this in the kernel,

It's not even that I will drop the patches, it's literally that "fixing" 
the code so that gcc doesn't complain can be a BUG. We've gone through 
that. 

		Linus

  parent reply	other threads:[~2004-11-23 18:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-21 22:55 Jesper Juhl
2004-11-22  1:02 ` Matthew Wilcox
2004-11-23  9:42   ` Jesper Juhl
2004-11-23 10:42     ` Jamie Lokier
2004-11-23 18:28       ` Bryan Henderson
2004-11-23 18:03     ` Linus Torvalds [this message]
2004-11-23 18:39       ` Jesper Juhl
2004-11-23 18:37         ` Linus Torvalds
2004-11-23 19:20           ` linux-os
2004-11-23 23:16           ` Jesper Juhl
2004-11-23 19:13       ` Timur Tabi
2004-11-23 23:09         ` Jesper Juhl
2004-11-23 23:03           ` Timur Tabi
2004-11-23 23:19             ` Jesper Juhl
2004-11-23 23:09               ` Timur Tabi
2004-11-23 23:28                 ` Jesper Juhl
2004-11-25 22:34             ` Valdis.Kletnieks

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=Pine.LNX.4.58.0411230958260.20993@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=juhl-lkml@dif.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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

all inboxes | Powered by JetHome®