public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jesper Juhl <juhl-lkml@dif.dk>
To: Matthew Wilcox <matthew@wil.cx>, Linus Torvalds <torvalds@osdl.org>
Cc: 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:42:42 +0100	[thread overview]
Message-ID: <41A30612.2040700@dif.dk> (raw)
In-Reply-To: <20041122010253.GE25636@parcelfarce.linux.theplanet.co.uk>

Matthew Wilcox wrote:
> On Sun, Nov 21, 2004 at 11:55:23PM +0100, Jesper Juhl wrote:
> 
>>This patch removes a pointless comparison. "arg" is an unsigned long, thus 
>>it can never be <0, so testing that is pointless.
>>
>>Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
>>
>> 	case F_SETSIG:
>> 		/* arg == 0 restores default behaviour. */
>>-		if (arg < 0 || arg > _NSIG) {
>>+		if (arg > _NSIG) {
>> 			break;
> 
> 
> I've seen patches like this before.  I'm generally in favour of removing
> the unnecessary test, but Linus rejected it on the grounds the compiler
> shouldn't be warning about it and it's better to be more explicit about
> the range test.  Maybe he's changed his mind between then and now ;-)
> 
Let's find out.
Linus, would you accept patches like this?

I've been building recent kernels with -W and there are tons of places 
with similar comparisons like the one above, as well as places where 
signed and unsigned values are compared, places where values are 
potentially truncated in signed/unsigned assignments and similar.
At the very least a review of these code locations to make sure they are 
all safe would make sense, and I think it would also make sense to get 
rid of the comparisons that always evaluate true or false due to the 
signedness or range of datatypes.
I probably won't be able to properly evaluate/review *all* the instances 
of this in the kernel, but I don't mind spending some time reviewing 
what I can and submit patches, but I don't want to waste my time with it 
if you already know up-front that you'll just be dropping all such 
patches. Or is this up to the individual maintainers to accept/reject? 
If so, then I'll go ahead and submit patches, then the individual 
maintainers can ack/nack as they please.

Comments?


--
Jesper Juhl




  reply	other threads:[~2004-11-23  9:46 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-21 22:55 [PATCH] Remove pointless <0 comparison for unsigned variable in fs/fcntl.c Jesper Juhl
2004-11-22  1:02 ` Matthew Wilcox
2004-11-23  9:42   ` Jesper Juhl [this message]
2004-11-23 10:42     ` Jamie Lokier
2004-11-23 18:28       ` Bryan Henderson
2004-11-23 18:03     ` Linus Torvalds
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=41A30612.2040700@dif.dk \
    --to=juhl-lkml@dif.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=torvalds@osdl.org \
    /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