diff mbox

sungem: limit reaches -1, but 0 tested

Message ID 4984473C.1040508@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

roel kluin Jan. 31, 2009, 12:42 p.m. UTC
With a postfix decrement these reach -1 rather than 0,
but after the loop it is tested to have become 0.

Signed-off-by: Roel Kluin <roel.kluin@gmail.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

Comments

David Miller Feb. 1, 2009, 9:59 a.m. UTC | #1
From: Roel Kluin <roel.kluin@gmail.com>
Date: Sat, 31 Jan 2009 13:42:36 +0100

> With a postfix decrement these reach -1 rather than 0,
> but after the loop it is tested to have become 0.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>

Just like the case just pointed out in your 'net' version
of this patch, it is being tested "<= 0" so this fix
is not necessary at all.

Please carefully review all of your changes of this kind
to make sure the test is strictly equality to zero rather
than <= 0.

I'm dropping all of these postfix decrement patches.
--
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
diff mbox

Patch

diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c
index 61843fd..78f8cee 100644
--- a/drivers/net/sungem_phy.c
+++ b/drivers/net/sungem_phy.c
@@ -79,7 +79,7 @@  static int reset_one_mii_phy(struct mii_phy* phy, int phy_id)
 
 	udelay(100);
 
-	while (limit--) {
+	while (--limit) {
 		val = __phy_read(phy, phy_id, MII_BMCR);
 		if ((val & BMCR_RESET) == 0)
 			break;