Skip to content

Commit 5f3f24f

Browse files
Alexey DobriyanDavid S. Miller
authored andcommitted
[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 <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 2ee92d4 commit 5f3f24f

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/atm/ambassador.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ static int make_rate (unsigned int rate, rounding r,
972972
}
973973
case round_up: {
974974
// check all bits that we are discarding
975-
if (man & (-1>>9)) {
975+
if (man & (~0U>>9)) {
976976
man = (man>>(32-9)) + 1;
977977
if (man == (1<<9)) {
978978
// no need to check for round up outside of range

‎drivers/atm/firestream.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ static unsigned int make_rate (unsigned int rate, int r,
512512
}
513513
case ROUND_UP: {
514514
/* check all bits that we are discarding */
515-
if (man & (-1>>9)) {
515+
if (man & (~0U>>9)) {
516516
man = (man>>(32-9)) + 1;
517517
if (man == (1<<9)) {
518518
/* no need to check for round up outside of range */

0 commit comments

Comments
 (0)