[ATM] ambassador,firestream: "-1 >>" is implementation defined
authorAlexey Dobriyan <adobriyan@gmail.com>
Tue, 14 Nov 2006 00:12:08 +0000 (16:12 -0800)
committerDavid S. Miller <davem@sunset.davemloft.net>
Sun, 3 Dec 2006 05:22:25 +0000 (21:22 -0800)
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 <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/atm/ambassador.c
drivers/atm/firestream.c

index 9fffa7af6db1f5c2feaf448fd7dec744e41ab308..afa7d750a59372c8087ae9dd8cf2fb4d5dc8c015 100644 (file)
@@ -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
index 697ad82f6634e2f74e4c3298d17f6ac13d0162cc..9c67df5ccfa432df69acf4c335ca0707724e7363 100644 (file)
@@ -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 */