All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: phy: initialize ge and fe variables
@ 2021-05-30 19:29 trix
  2021-06-01  5:22 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2021-05-30 19:29 UTC (permalink / raw)
  To: pgwipeout, andrew, hkallweit1, linux, davem, kuba
  Cc: netdev, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

Static analysis reports this issue
/motorcomm.c:83:2: warning: variable 'ge' is used uninitialized
  whenever switch default is taken [-Wsometimes-uninitialized]
        default: /* leave everything alone in other modes */
        ^~~~~~~
drivers/net/phy/motorcomm.c:87:85: note: uninitialized use
  occurs here
        ret = __phy_modify(phydev, YT8511_PAGE,
	  (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
                                                     ^~

__phy_modify() calls __mdiobus_modify_changed(.., mask, set)

	new = (ret & ~mask) | set;
	if (new == ret)
		return 0;

	ret = __mdiobus_write(bus, addr, regnum, new);

Since 'ge/set' is or-ed in, it is safe to initialize it to 0

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/net/phy/motorcomm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 796b68f4b499..53b2906c54ef 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -50,7 +50,7 @@ static int yt8511_write_page(struct phy_device *phydev, int page)
 
 static int yt8511_config_init(struct phy_device *phydev)
 {
-	unsigned int ge, fe;
+	unsigned int ge = 0, fe = 0;
 	int ret, oldpage;
 
 	/* set clock mode to 125mhz */
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-01  5:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-30 19:29 [PATCH] net: phy: initialize ge and fe variables trix
2021-06-01  5:22 ` Jakub Kicinski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.