Re: 2.4.21-pre4 comparison bugs

From: Bill Davidsen (davidsen@tmr.com)
Date: Sun Feb 16 2003 - 21:10:21 EST


On Sun, 9 Feb 2003, J.A. Magallon wrote:

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

Fuzzy thinking and non-portable. I think the answer is that someone didn't
put enough thought into the error returns. This is trickery to avoid
defining an error value to return. One of those "it works on most
compilers and computers" things. Definitely low human readability. If the
return value is always small enough to be positive if cast to (int), why
not return int? Can't say without looking at actual code rather than a
general example.

Because it mostly works, I'm not sure what priority a more readable return
code would have, though.

-- 
bill davidsen <davidsen@tmr.com>
  CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.

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



This archive was generated by hypermail 2b29 : Sun Feb 23 2003 - 22:00:16 EST