lkml.org 
[lkml]   [2003]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.4.21-pre4 comparison bugs

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.
>

So:

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 <jamagallon@able.es> \ Software is like sex:
werewolf.able.es \ 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.068 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site