Re: Style question: comparison between signed and unsigned?

Dean Gaudet (dgaudet-list-linux-kernel@arctic.org)
Mon, 22 Sep 1997 17:28:12 -0700 (PDT)


On Mon, 22 Sep 1997, Linus Torvalds wrote:

> Now, the PROBLEM is that if gcc warns about signed/unsigned comparisons
> (which some versions of gcc do), gcc will totally needlessly (and in my
> opinion incorrectly) warn about the second test (ie "i < sizeof(struct
> pkthdr)"). Because "i" is signed, but "sizeof" is unsigned.

I know this is where the warning is generated. But my claim is that this
supposedly "bad" code is forced due to the lame prototype for read().
Overloaded return values are bad.

You could misinterpret the compiler's warning to mean you need a cast ...
but really it means you need to redesign your code :)

Now that'll never happen for things like read(). So it makes this warning
absolutely useless in its current incarnation.

Dean