From: Alexey Dobriyan Date: Tue, 14 Nov 2006 00:12:08 +0000 (-0800) Subject: [ATM] ambassador,firestream: "-1 >>" is implementation defined X-Git-Tag: v2.6.20-rc2~6^2~13^2~388 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f3f24faf322e54752d1df00cdb768a013de5d1f;p=platform%2Fupstream%2Fkernel-adaptation-pc.git [ATM] ambassador,firestream: "-1 >>" is implementation defined 6.5.7(5): The result of E1 >> E2 is E1 right-shifted E2 bit positions. ... If E1 has a signed type and a negative value, the resulting value is implementation defined. So, cast -1 to unsigned type to make result well-defined. [ Modified to use ~0U based upon recommendation from Al Viro. -DaveM ] Signed-off-by: Alexey Dobriyan Signed-off-by: David S. Miller --- diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c index 9fffa7a..afa7d75 100644 --- a/drivers/atm/ambassador.c +++ b/drivers/atm/ambassador.c @@ -972,7 +972,7 @@ static int make_rate (unsigned int rate, rounding r, } case round_up: { // check all bits that we are discarding - if (man & (-1>>9)) { + if (man & (~0U>>9)) { man = (man>>(32-9)) + 1; if (man == (1<<9)) { // no need to check for round up outside of range diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c index 697ad82..9c67df5 100644 --- a/drivers/atm/firestream.c +++ b/drivers/atm/firestream.c @@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r, } case ROUND_UP: { /* check all bits that we are discarding */ - if (man & (-1>>9)) { + if (man & (~0U>>9)) { man = (man>>(32-9)) + 1; if (man == (1<<9)) { /* no need to check for round up outside of range */