lkml.org 
[lkml]   [2003]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 2.4.21-pre4 comparison bugs
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/

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