]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[ATM] ambassador, firestream: "-1 >>" is implementation defined
authorAlexey Dobriyan <adobriyan@gmail.com>
Wed, 21 Feb 2007 00:43:24 +0000 (01:43 +0100)
committerAdrian Bunk <bunk@stusta.de>
Wed, 21 Feb 2007 00:43:24 +0000 (01:43 +0100)
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: Adrian Bunk <bunk@stusta.de>
drivers/atm/ambassador.c
drivers/atm/firestream.c

index 4b6bf19c39c004d4b2277f11e68ac2ea59a4b753..15cb680b5ea45a78118b3ac48287147b421f3031 100644 (file)
@@ -978,7 +978,7 @@ static unsigned 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 01eebd1ab80d6f3199e01f5f753ef80cb1cd6b43..75bc1eb2d526eeaf5b985fb3e6b063d3d05c60c5 100644 (file)
@@ -511,7 +511,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 */