* [PATCH] net: xgene: fix maybe-uninitialized variable
@ 2016-08-02 10:23 Arnd Bergmann
2016-08-03 18:52 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-08-02 10:23 UTC (permalink / raw)
To: Iyappan Subramanian, Keyur Chudgar
Cc: Arnd Bergmann, David S. Miller, Tanmay Inamdar, netdev,
linux-kernel
Building with -Wmaybe-uninitialized shows a potential use of
an uninitialized variable:
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c: In function 'xgene_enet_phy_connect':
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c:802:23: warning: 'phy_dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
Although the compiler correctly identified this based on the function,
the current code is still safe as long dev->of_node is non-NULL
for the case of CONFIG_ACPI=n, which is currently the case.
The warning is now disabled by default, but still appears when
building with W=1, and other build test tools should be able to
detect it as well. Adding an #else clause here makes the code
more robust and makes it clear to the compiler that this cannot
happen.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 8089a96f601b ("drivers: net: xgene: Add backward compatibility")
---
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 7714b7d4026a..98779fe2d558 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -792,6 +792,8 @@ int xgene_enet_phy_connect(struct net_device *ndev)
netdev_err(ndev, "Could not connect to PHY\n");
return -ENODEV;
}
+#else
+ return -ENODEV;
#endif
}
--
2.9.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: xgene: fix maybe-uninitialized variable
2016-08-02 10:23 [PATCH] net: xgene: fix maybe-uninitialized variable Arnd Bergmann
@ 2016-08-03 18:52 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-08-03 18:52 UTC (permalink / raw)
To: arnd; +Cc: isubramanian, kchudgar, tinamdar, netdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 2 Aug 2016 12:23:29 +0200
> Building with -Wmaybe-uninitialized shows a potential use of
> an uninitialized variable:
>
> drivers/net/ethernet/apm/xgene/xgene_enet_hw.c: In function 'xgene_enet_phy_connect':
> drivers/net/ethernet/apm/xgene/xgene_enet_hw.c:802:23: warning: 'phy_dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Although the compiler correctly identified this based on the function,
> the current code is still safe as long dev->of_node is non-NULL
> for the case of CONFIG_ACPI=n, which is currently the case.
>
> The warning is now disabled by default, but still appears when
> building with W=1, and other build test tools should be able to
> detect it as well. Adding an #else clause here makes the code
> more robust and makes it clear to the compiler that this cannot
> happen.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 8089a96f601b ("drivers: net: xgene: Add backward compatibility")
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-03 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 10:23 [PATCH] net: xgene: fix maybe-uninitialized variable Arnd Bergmann
2016-08-03 18:52 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).