Skip to contentSkip to conversation

cxgb4: silence shift wrapping static checker warning

PATCH Applied Dan Carpenter 3 participants 3 messages Jan 9, 2014 – Jan 13, 2014

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

PATCH 1/1 cxgb4: silence shift wrapping static checker warning

I don't know how large "tp->vlan_shift" is but static checkers worry about shift wrapping bugs here.

drivers/net/ethernet/chelsio/cxgb4/l2t.c +1 -1
index cb05be905def..81e8402a74b4 100644
@@ -423,7 +423,7 @@ u64 cxgb4_select_ntuple(struct net_device *dev,
 	 * in the Compressed Filter Tuple.
 	 */
 	if (tp->vlan_shift >= 0 && l2t->vlan != VLAN_NONE)
-		ntuple |= (F_FT_VLAN_VLD | l2t->vlan) << tp->vlan_shift;
+		ntuple |= (u64)(F_FT_VLAN_VLD | l2t->vlan) << tp->vlan_shift;
 
 	if (tp->port_shift >= 0)
 		ntuple |= (u64)l2t->lport << tp->port_shift;
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines

I don't know how large "tp->vlan_shift" is but static checkers worry about shift wrapping bugs here.

Indeed.

Quoted 1 line
Quoted 14 lines
drivers/net/ethernet/chelsio/cxgb4/l2t.c +1 -1
index cb05be905def..81e8402a74b4 100644
@@ -423,7 +423,7 @@ u64 cxgb4_select_ntuple(struct net_device *dev,
 	 * in the Compressed Filter Tuple.
 	 */
 	if (tp->vlan_shift >= 0 && l2t->vlan != VLAN_NONE)
-		ntuple |= (F_FT_VLAN_VLD | l2t->vlan) << tp->vlan_shift;
+		ntuple |= (u64)(F_FT_VLAN_VLD | l2t->vlan) << tp->vlan_shift;
 
 	if (tp->port_shift >= 0)
 		ntuple |= (u64)l2t->lport << tp->port_shift;