Re: [PATCH] fs/fcntl.c : don't test unsigned value for less than zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christoph Hellwig <[email protected]> wrote:
>
>> No, it was exactly this patch:
>> http://www.ussg.iu.edu/hypermail/linux/kernel/0401.0/1816.html
> 
> Hmm.  Looks I absolutely disagree with Linus on this one ;-)

Me too.  The compiler doesn't really have much choice here.  If
it ignores all comparisons of unsigned integers to less than zero
then we could miss real bugs like this:

int foo(unsigned int val)
{
	return val < 0;
}

where the user probably wanted a signed comparison.

I suppose it could be smart and stay quiet about

val < 0 || val > BOUND

However, gcc is slow enough as it is without adding unnecessary
smarts like this.
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux