Re: Recent change in tcp_output.c is surely wrong

From: Matthew Wilcox (willy@thepuffingroup.com)
Date: Tue Jan 18 2000 - 11:28:47 EST


On Tue, Jan 18, 2000 at 10:27:48AM -0500, Richard B. Johnson wrote:
> Well it's a problem if it doesn't work.
> int foo0 (int bar)
            ^^^
> {
> return bar & 0x7fffffff;
> }
>
> int foo1 (int bar)
            ^^^
> {
> return ((bar << 1) >> 1);
> }
>
> int main()
> {
> int xxx = 0xffffffff;
     ^^^
> printf("%d\n", foo0(xxx));
> printf("%d\n", foo1(xxx));
> return 0;
> }

> So, the double-shift is truly broken. Just AND it and be done with it.

int is signed. the discussion relates to unsigned ints.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:18 EST