netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: trix@redhat.com
To: pgwipeout@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com,
	linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Tom Rix <trix@redhat.com>
Subject: [PATCH] net: phy: initialize ge and fe variables
Date: Sun, 30 May 2021 12:29:43 -0700	[thread overview]
Message-ID: <20210530192943.2556076-1-trix@redhat.com> (raw)

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


             reply	other threads:[~2021-05-30 19:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-30 19:29 trix [this message]
2021-06-01  5:22 ` [PATCH] net: phy: initialize ge and fe variables Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210530192943.2556076-1-trix@redhat.com \
    --to=trix@redhat.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pgwipeout@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).