* [PATCH] e1000: Fix tests of unsigned in e1000_tx_map()
@ 2009-12-15 18:18 Roel Kluin
2009-12-15 18:47 ` roel kluin
0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-12-15 18:18 UTC (permalink / raw)
To: Jeff Kirsher, Jesse Brandeburg, Bruce Allan, PJ Waskiewicz,
John Ronciak, e1000-devel, Andrew Morton, LKML
The variables count and i are unsigned so the (<|>=) 0 tests do not work.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Found using coccinelle: http://coccinelle.lip6.fr/
I wasn't able to test this, so please review.
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7e855f9..8d9da69 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2802,13 +2802,13 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
- count--;
-
- while (count >= 0) {
+ if (count)
count--;
- i--;
- if (i < 0)
+
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
e1000_unmap_and_free_tx_resource(adapter, buffer_info);
}
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 762b697..9be8d5d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3962,13 +3962,13 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
- count--;
-
- while (count >= 0) {
+ if (count)
count--;
- i--;
- if (i < 0)
+
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
e1000_put_txbuf(adapter, buffer_info);;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] e1000: Fix tests of unsigned in e1000_tx_map()
2009-12-15 18:18 [PATCH] e1000: Fix tests of unsigned in e1000_tx_map() Roel Kluin
@ 2009-12-15 18:47 ` roel kluin
2009-12-15 19:02 ` Roel Kluin
0 siblings, 1 reply; 4+ messages in thread
From: roel kluin @ 2009-12-15 18:47 UTC (permalink / raw)
To: Jeff Kirsher, Jesse Brandeburg, Bruce Allan, PJ Waskiewicz,
John Ronciak, e1000-devel, Andrew Morton, LKML
On Tue, Dec 15, 2009 at 7:18 PM, Roel Kluin <roel.kluin@gmail.com> wrote:
> The variables count and i are unsigned so the (<|>=) 0 tests do not work.
I now see there are similar issues in igb and friends,
I'll post a patch that includes these as well.
Roel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] e1000: Fix tests of unsigned in e1000_tx_map()
2009-12-15 18:47 ` roel kluin
@ 2009-12-15 19:02 ` Roel Kluin
2009-12-22 23:50 ` Jeff Kirsher
0 siblings, 1 reply; 4+ messages in thread
From: Roel Kluin @ 2009-12-15 19:02 UTC (permalink / raw)
To: Jeff Kirsher, Jesse Brandeburg, Bruce Allan, PJ Waskiewicz,
John Ronciak, e1000-devel, Andrew Morton, LKML
The variables count and i are unsigned so the (<|>=) 0 tests do not work.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Found using coccinelle: http://coccinelle.lip6.fr/
This should be all with this pattern.
As before I wasn't able to test this patch, so please review.
drivers/net/e1000/e1000_main.c | 10 +++++-----
drivers/net/e1000e/netdev.c | 10 +++++-----
drivers/net/igb/igb_main.c | 10 +++++-----
drivers/net/igbvf/netdev.c | 10 +++++-----
drivers/net/ixgb/ixgb_main.c | 10 +++++-----
drivers/net/ixgbe/ixgbe_main.c | 10 +++++-----
6 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c
index 7e855f9..8d9da69 100644
--- a/drivers/net/e1000/e1000_main.c
+++ b/drivers/net/e1000/e1000_main.c
@@ -2802,13 +2802,13 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
- count--;
-
- while (count >= 0) {
+ if (count)
count--;
- i--;
- if (i < 0)
+
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
e1000_unmap_and_free_tx_resource(adapter, buffer_info);
}
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 762b697..9be8d5d 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -3962,13 +3962,13 @@ static int e1000_tx_map(struct e1000_adapter *adapter,
dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
- count--;
-
- while (count >= 0) {
+ if (count)
count--;
- i--;
- if (i < 0)
+
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
e1000_put_txbuf(adapter, buffer_info);;
}
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 78963a0..2b08fdd 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -3627,14 +3627,14 @@ dma_error:
buffer_info->length = 0;
buffer_info->next_to_watch = 0;
buffer_info->mapped_as_page = false;
- count--;
+ if (count)
+ count--;
/* clear timestamp and dma mappings for remaining portion of packet */
- while (count >= 0) {
- count--;
- i--;
- if (i < 0)
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
igb_unmap_and_free_tx_resource(tx_ring, buffer_info);
}
diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c
index e9dd95f..2eb95fe 100644
--- a/drivers/net/igbvf/netdev.c
+++ b/drivers/net/igbvf/netdev.c
@@ -2163,14 +2163,14 @@ dma_error:
buffer_info->length = 0;
buffer_info->next_to_watch = 0;
buffer_info->mapped_as_page = false;
- count--;
+ if (count)
+ count--;
/* clear timestamp and dma mappings for remaining portion of packet */
- while (count >= 0) {
- count--;
- i--;
- if (i < 0)
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
igbvf_put_txbuf(adapter, buffer_info);
}
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c
index bcd0f01..fffd254 100644
--- a/drivers/net/ixgb/ixgb_main.c
+++ b/drivers/net/ixgb/ixgb_main.c
@@ -1363,13 +1363,13 @@ ixgb_tx_map(struct ixgb_adapter *adapter, struct sk_buff *skb,
dma_error:
dev_err(&pdev->dev, "TX DMA map failed\n");
buffer_info->dma = 0;
- count--;
-
- while (count >= 0) {
+ if (count)
count--;
- i--;
- if (i < 0)
+
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
buffer_info = &tx_ring->buffer_info[i];
ixgb_unmap_and_free_tx_resource(adapter, buffer_info);
}
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 35ea8c9..60b3551 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -5143,14 +5143,14 @@ dma_error:
tx_buffer_info->dma = 0;
tx_buffer_info->time_stamp = 0;
tx_buffer_info->next_to_watch = 0;
- count--;
+ if (count)
+ count--;
/* clear timestamp and dma mappings for remaining portion of packet */
- while (count >= 0) {
- count--;
- i--;
- if (i < 0)
+ while (count--) {
+ if (i == 0)
i += tx_ring->count;
+ i--;
tx_buffer_info = &tx_ring->tx_buffer_info[i];
ixgbe_unmap_and_free_tx_resource(adapter, tx_buffer_info);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] e1000: Fix tests of unsigned in e1000_tx_map()
2009-12-15 19:02 ` Roel Kluin
@ 2009-12-22 23:50 ` Jeff Kirsher
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Kirsher @ 2009-12-22 23:50 UTC (permalink / raw)
To: Roel Kluin
Cc: Jesse Brandeburg, Bruce Allan, PJ Waskiewicz, John Ronciak,
e1000-devel, Andrew Morton, LKML
On Tue, Dec 15, 2009 at 11:02, Roel Kluin <roel.kluin@gmail.com> wrote:
> The variables count and i are unsigned so the (<|>=) 0 tests do not work.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> Found using coccinelle: http://coccinelle.lip6.fr/
>
> This should be all with this pattern.
> As before I wasn't able to test this patch, so please review.
>
> drivers/net/e1000/e1000_main.c | 10 +++++-----
> drivers/net/e1000e/netdev.c | 10 +++++-----
> drivers/net/igb/igb_main.c | 10 +++++-----
> drivers/net/igbvf/netdev.c | 10 +++++-----
> drivers/net/ixgb/ixgb_main.c | 10 +++++-----
> drivers/net/ixgbe/ixgbe_main.c | 10 +++++-----
> 6 files changed, 30 insertions(+), 30 deletions(-)
>
Thanks Roel, I will add this patch to my queue. Sorry for the delayed
response, for some odd reason your email got filtered.
--
Cheers,
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-22 23:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-15 18:18 [PATCH] e1000: Fix tests of unsigned in e1000_tx_map() Roel Kluin
2009-12-15 18:47 ` roel kluin
2009-12-15 19:02 ` Roel Kluin
2009-12-22 23:50 ` Jeff Kirsher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox