netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: off by one, try #2
@ 2009-02-11 10:01 Roel Kluin
  2009-02-11 13:33 ` Jarek Poplawski
  0 siblings, 1 reply; 12+ messages in thread
From: Roel Kluin @ 2009-02-11 10:01 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Andrew Morton

Better?

-------------------->8----------------8<-----------------------
With while (x++ < n) { ... } x can reach n+1.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
 drivers/net/3c505.c        |    4 ++--
 drivers/net/irda/mcs7780.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c
index 6124605..fb74846 100644
--- a/drivers/net/3c505.c
+++ b/drivers/net/3c505.c
@@ -500,9 +500,9 @@ static bool receive_pcb(struct net_device *dev, pcb_struct * pcb)
 		pcb->data.raw[i++] = inb_command(dev->base_addr);
 		if (i > MAX_PCB_DATA)
 			INVALID_PCB_MSG(i);
-	} while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j < 20000);
+	} while ((stat & ASF_PCB_MASK) != ASF_PCB_END && j <= 20000);
 	spin_unlock_irqrestore(&adapter->lock, flags);
-	if (j >= 20000) {
+	if (j > 20000) {
 		TIMEOUT_MSG(__LINE__);
 		return false;
 	}
diff --git a/drivers/net/irda/mcs7780.c b/drivers/net/irda/mcs7780.c
index 7eafdca..b4f4f19 100644
--- a/drivers/net/irda/mcs7780.c
+++ b/drivers/net/irda/mcs7780.c
@@ -585,7 +585,7 @@ static int mcs_speed_change(struct mcs_cb *mcs)
 		mcs_get_reg(mcs, MCS_RESV_REG, &rval);
 	} while(cnt++ < 100 && (rval & MCS_IRINTX));
 
-	if(cnt >= 100) {
+	if(cnt > 100) {
 		IRDA_ERROR("unable to change speed\n");
 		ret = -EIO;
 		goto error;

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

end of thread, other threads:[~2009-02-13  0:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-11 10:01 [PATCH] net: off by one, try #2 Roel Kluin
2009-02-11 13:33 ` Jarek Poplawski
2009-02-11 14:22   ` Roel Kluin
2009-02-11 17:14     ` Jarek Poplawski
2009-02-11 19:33       ` Roel Kluin
2009-02-11 20:27         ` Jarek Poplawski
2009-02-11 20:58           ` Jarek Poplawski
2009-02-11 22:55             ` [PATCH] 3c505: do not set pcb->data.raw beyond its size Roel Kluin
2009-02-12  6:37               ` Jarek Poplawski
2009-02-13  0:52                 ` David Miller
2009-02-11 21:22           ` [PATCH] IRDA: cnt is off by 1 Roel Kluin
2009-02-13  0:42             ` 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).