Re: 2.4.21-pre4 comparison bugs

From: J.A. Magallon (
Date: Sat Feb 08 2003 - 18:25:10 EST

On 2003.02.08 Oleg Drokin wrote:
> Hello!
> Thanks to whoever mentioned "gcc -W", it's *sweet* ;)
> Looking at it's output I found few cases where error checking
> does not work.
> Though nothing too serious it seems (except maybe IDE setup-pci stuff,
> I just do not know about that, and may be in that case
> we actually want to change all the functions to return signed
> value, though my fix is certainly less intrusive ;) )
> Most of the patched stuff in here assigns signed value to unsigned
> variable and then checks if it is less than zero which does not work
> for obvious reasons ;)
> I decided taht in most cases simple casting to int would be best
> and least intrusive resolution of a problem.
> The only exception is fs/isofs/inode.c, there we have unsigned int
> (so it is unsigned not depending on any arch) and so '> some num'
> stuff will also check for former negative numbers anyway. So
> I removed one extra comparison in that case.
> See the patch below.


unsgined f()
        return -1;

if ((int)f()<0)

Wouldn't you get killed by some kind of bit/sign extension in the return ?
Just to be sure, probably the answer is just 'go learn C internals'...

J.A. Magallon <>      \                 Software is like sex:                         \           It's better when it's free
Mandrake Linux release 9.1 (Cooker) for i586
Linux 2.4.21-pre4-jam1 (gcc 3.2.1 (Mandrake Linux 9.1 3.2.1-5mdk))
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Feb 15 2003 - 22:00:20 EST