Skip to contentSkip to conversation

: bnx2: Fix uninitialized variable warning in bnx2_disable_forced_2g5()

PATCH In review Prarit Bhargava 2 participants 2 messages May 27, 2010

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

PATCH 1/1 : bnx2: Fix uninitialized variable warning in bnx2_disable_forced_2g5()

Fix warning:

drivers/net/bnx2.c: In function 'bnx2_disable_forced_2g5':
drivers/net/bnx2.c:1489: warning: 'bmcr' may be used uninitialized in this function

drivers/net/bnx2.c +1 -1
index 667f419..7e2f8ac 100644
@@ -1486,7 +1486,7 @@ bnx2_enable_forced_2g5(struct bnx2 *bp)
 static void
 bnx2_disable_forced_2g5(struct bnx2 *bp)
 {
-	u32 bmcr;
+	u32 uninitialized_var(bmcr);
 
 	if (!(bp->phy_flags & BNX2_PHY_FLAG_2_5G_CAPABLE))
 		return;
maintainer
#1 lore raw

From: Prarit Bhargava <[email protected]>
Date: Thu, 27 May 2010 18:13:01 -0400

Quoted 6 lines

Fix warning:

drivers/net/bnx2.c: In function 'bnx2_disable_forced_2g5':
drivers/net/bnx2.c:1489: warning: 'bmcr' may be used uninitialized in this function

This is another bad patch, you're hiding a bug by making this warning go away.

If bnx2_read_phy() in fact does not initialize "bmcr" we might want to do something about that instead of just blindly using whatever garbage is in that local variable.

Please stop making these patches without applying at least some intelligence to the analysis of why these warnings are being printed at all.

None of these cases you're posting patches for are situations where the compiler simply can't see the control flow properly, they are real issues.

Thanks.