* Re: [PATCH] atm: Cleanup redundant tests on unsigned
2009-10-23 16:09 [PATCH] atm: Cleanup redundant tests on unsigned Roel Kluin
@ 2009-10-23 16:08 ` Eric Dumazet
2009-10-24 13:19 ` David Miller
2009-10-29 8:40 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2009-10-23 16:08 UTC (permalink / raw)
To: Roel Kluin; +Cc: Chas Williams, netdev, Andrew Morton
Roel Kluin a écrit :
> The variables are unsigned so the `< 0' test always fails, the
> other part of the test catches wrapped values.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
I believe such patches were posted in the past.
General consensus is that compiler is able to do this optimization for us,
and reader doesnt have to ask to himself : "Is the test safe enough ?"
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] atm: Cleanup redundant tests on unsigned
@ 2009-10-23 16:09 Roel Kluin
2009-10-23 16:08 ` Eric Dumazet
2009-10-29 8:40 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Roel Kluin @ 2009-10-23 16:09 UTC (permalink / raw)
To: Chas Williams, netdev, Andrew Morton
The variables are unsigned so the `< 0' test always fails, the
other part of the test catches wrapped values.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
drivers/atm/fore200e.c | 4 ++--
drivers/atm/he.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
index f766cc4..bc53fed 100644
--- a/drivers/atm/fore200e.c
+++ b/drivers/atm/fore200e.c
@@ -2906,8 +2906,8 @@ fore200e_proc_read(struct atm_dev *dev, loff_t* pos, char* page)
u32 media_index = FORE200E_MEDIA_INDEX(fore200e->bus->read(&fore200e->cp_queues->media_type));
u32 oc3_index;
- if ((media_index < 0) || (media_index > 4))
- media_index = 5;
+ if (media_index > 4)
+ media_index = 5;
switch (fore200e->loop_mode) {
case ATM_LM_NONE: oc3_index = 0;
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index 7066703..e906658 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -2739,7 +2739,7 @@ he_ioctl(struct atm_dev *atm_dev, unsigned int cmd, void __user *arg)
spin_lock_irqsave(&he_dev->global_lock, flags);
switch (reg.type) {
case HE_REGTYPE_PCI:
- if (reg.addr < 0 || reg.addr >= HE_REGMAP_SIZE) {
+ if (reg.addr >= HE_REGMAP_SIZE) {
err = -EINVAL;
break;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] atm: Cleanup redundant tests on unsigned
2009-10-23 16:08 ` Eric Dumazet
@ 2009-10-24 13:19 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2009-10-24 13:19 UTC (permalink / raw)
To: eric.dumazet; +Cc: roel.kluin, chas, netdev, akpm
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 23 Oct 2009 18:08:30 +0200
> Roel Kluin a écrit :
>> The variables are unsigned so the `< 0' test always fails, the
>> other part of the test catches wrapped values.
>>
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>> ---
>
> I believe such patches were posted in the past.
>
> General consensus is that compiler is able to do this optimization for us,
> and reader doesnt have to ask to himself : "Is the test safe enough ?"
Conversely, the reader can say "Wow this can be negative? There's
tests missing elsewhere! ... oh, nevermind it's unsigned"
That really wastes people's time too.
I suspect I'll apply these patches. :-)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] atm: Cleanup redundant tests on unsigned
2009-10-23 16:09 [PATCH] atm: Cleanup redundant tests on unsigned Roel Kluin
2009-10-23 16:08 ` Eric Dumazet
@ 2009-10-29 8:40 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2009-10-29 8:40 UTC (permalink / raw)
To: roel.kluin; +Cc: chas, netdev, akpm
From: Roel Kluin <roel.kluin@gmail.com>
Date: Fri, 23 Oct 2009 18:09:55 +0200
> The variables are unsigned so the `< 0' test always fails, the
> other part of the test catches wrapped values.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-29 8:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-23 16:09 [PATCH] atm: Cleanup redundant tests on unsigned Roel Kluin
2009-10-23 16:08 ` Eric Dumazet
2009-10-24 13:19 ` David Miller
2009-10-29 8:40 ` 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).