Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522630 > unrolled thread

[PATCH] amd-xgbe: fix unsigned comparison against less than zero

Started byColin King <colin.king@canonical.com>
First post2016-11-15 13:20 +0100
Last post2016-11-15 13:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] amd-xgbe: fix unsigned comparison against less than zero Colin King <colin.king@canonical.com> - 2016-11-15 13:20 +0100

#1522630 — [PATCH] amd-xgbe: fix unsigned comparison against less than zero

FromColin King <colin.king@canonical.com>
Date2016-11-15 13:20 +0100
Subject[PATCH] amd-xgbe: fix unsigned comparison against less than zero
Message-ID<sDKSt-4PB-5@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

Comparing unsigned int ret to less than zero for an error status
check is never true.  Fix this by making ret a signed int. Reduce
scope of ret too.

Found with static analysis by CoverityScan, CID 1377750

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
index 4ba4332..168507e 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c
@@ -2346,7 +2346,7 @@ static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
 static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
 {
 	struct xgbe_phy_data *phy_data = pdata->phy_data;
-	unsigned int ret, reg;
+	unsigned int reg;
 
 	*an_restart = 0;
 
@@ -2365,7 +2365,8 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart)
 
 	if (phy_data->phydev) {
 		/* Check external PHY */
-		ret = phy_read_status(phy_data->phydev);
+		int ret = phy_read_status(phy_data->phydev);
+
 		if (ret < 0)
 			return 0;
 
-- 
2.10.2

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web