Patchwork : bnx2: Fix uninitialized variable warning in bnx2_disable_forced_2g5()

login
register
mail settings
Submitter Prarit Bhargava
Date May 27, 2010, 10:13 p.m.
Message ID <20100527220856.25418.86593.sendpatchset@prarit.bos.redhat.com>
Download mbox | patch
Permalink /patch/53835/
State Rejected
Delegated to: David Miller
Headers show

Comments

Prarit Bhargava - May 27, 2010, 10:13 p.m.
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

Signed-off-by: Prarit Bhargava <prarit@redhat.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - May 27, 2010, 11:26 p.m.
From: Prarit Bhargava <prarit@redhat.com>
Date: Thu, 27 May 2010 18:13:01 -0400

> 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
> 
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>

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.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 667f419..7e2f8ac 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -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;