Skip to contentSkip to conversation

fm10k: drop upper bits of VLAN ID

PATCH In review Dan Carpenter 2 participants 3 messages Jan 30, 2015

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

PATCH 1/1 fm10k: drop upper bits of VLAN ID

Static checkers complain that the shifts in "(vid << 4) >> 4" perfectly cancel each other out and the code is a no-op. "vid" is a u16. The comment says that the intention here is to drop the upper bits so I have added a cast to "u16" to do that.

Fixes 401b5383c6c9 ('fm10k: Add support for configuring PF interface')

---
Static analysis. Not tested.

drivers/net/ethernet/intel/fm10k/fm10k_pf.c +1 -1
index 275423d..ee30d06 100644
@@ -335,7 +335,7 @@ static s32 fm10k_update_xc_addr_pf(struct fm10k_hw *hw, u16 glort,
 		return FM10K_ERR_PARAM;
 
 	/* drop upper 4 bits of VLAN ID */
-	vid = (vid << 4) >> 4;
+	vid = (u16)(vid << 4) >> 4;
 
 	/* record fields */
 	mac_update.mac_lower = cpu_to_le32(((u32)mac[2] << 24) |
#1 lore raw
Quoted 7 lines · Dan Carpenter

Static checkers complain that the shifts in "(vid << 4) >> 4" perfectly cancel each other out and the code is a no-op. "vid" is a u16. The comment says that the intention here is to drop the upper bits so I have added a cast to "u16" to do that.

Fixes 401b5383c6c9 ('fm10k: Add support for configuring PF interface')

Oh... Rasmus Villemoes already fixed this.

regards,
dan carpenter

#2 lore raw
Quoted 6 lines · Dan Carpenter
Quoted 5 lines · Dan Carpenter

Static checkers complain that the shifts in "(vid << 4) >> 4" perfectly cancel each other out and the code is a no-op. "vid" is a u16. The comment says that the intention here is to drop the upper bits so I have added a cast to "u16" to do that.

Quoted 7 lines
Quoted 2 lines
Fixes 401b5383c6c9 ('fm10k: Add support for configuring PF interface')

Oh... Rasmus Villemoes already fixed this.

regards,
dan carpenter

Yep, we have a patch coming through Jeff's tree now to resolve the issue (technically my version of the patch, which doesn't try to mask off the bits but instead rejects an out-of-bounds VLAN ID). Thanks, Dan!

Cheers,
Matthew