Skip to contentSkip to conversation

rocker: silence shift wrapping warning

PATCH Applied Dan Carpenter 4 participants 4 messages Feb 25, 2015 – Feb 27, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 rocker: silence shift wrapping warning

"val" is declared as a u64 so static checkers complain that this shift can wrap. I don't have the hardware but probably it's doesn't have over 31 ports. Still we may as well silence the warning even if it's not a real bug.

drivers/net/ethernet/rocker/rocker.c +2 -2
index 713a13c..9fb6948 100644
@@ -1257,9 +1257,9 @@ static void rocker_port_set_enable(struct rocker_port *rocker_port, bool enable)
 	u64 val = rocker_read64(rocker_port->rocker, PORT_PHYS_ENABLE);
 
 	if (enable)
-		val |= 1 << rocker_port->lport;
+		val |= 1ULL << rocker_port->lport;
 	else
-		val &= ~(1 << rocker_port->lport);
+		val &= ~(1ULL << rocker_port->lport);
 	rocker_write64(rocker_port->rocker, PORT_PHYS_ENABLE, val);
 }
 
maintainer Acked-by on v1 2/2
#1 lore raw
Quoted 2 lines · Wed, Feb 25, 2015 at 02:36:12PM CET, [email protected] wrote:

"val" is declared as a u64 so static checkers complain that this shift can wrap. I don't have the hardware but probably it's doesn't have over

It's a QEMU hardware, you can have it easily.

Quoted 2 lines

31 ports. Still we may as well silence the warning even if it's not a real bug.

It can have up to 62 ports.

Quoted 2 lines
Acked-by on v1 2/2
#2 lore raw
In reply to Dan Carpenter
Quoted 13 lines · Dan Carpenter

"val" is declared as a u64 so static checkers complain that this shift can wrap. I don't have the hardware but probably it's doesn't have over 31 ports. Still we may as well silence the warning even if it's not a real bug.

drivers/net/ethernet/rocker/rocker.c +0 -0
index 713a13c..9fb6948 100644
@@ -1257,9 +1257,9 @@ static void rocker_port_set_enable(struct rocker_port *rocker_port, bool enable)
        u64 val = rocker_read64(rocker_port->rocker, PORT_PHYS_ENABLE);

drivers/net/ethernet/rocker/rocker.c static void rocker_port_set_enable(struct rocker_port *rocker_port, bool enable) · line 1265

Quoted 10 lines
drivers/net/ethernet/rocker/rocker.c +2 -2
 
        if (enable)
-               val |= 1 << rocker_port->lport;
+               val |= 1ULL << rocker_port->lport;
        else
-               val &= ~(1 << rocker_port->lport);
+               val &= ~(1ULL << rocker_port->lport);
        rocker_write64(rocker_port->rocker, PORT_PHYS_ENABLE, val);
 }