diff mbox

[v3,1/4] net/macb: fix truncate warnings

Message ID 1350931534-8416-2-git-send-email-manabian@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joachim Eastwood Oct. 22, 2012, 6:45 p.m. UTC
When building macb on x86_64 the following warnings show up:
  drivers/net/ethernet/cadence/macb.c: In function macb_interrupt:
  drivers/net/ethernet/cadence/macb.c:556:4: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  drivers/net/ethernet/cadence/macb.c: In function macb_reset_hw:
  drivers/net/ethernet/cadence/macb.c:792:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  drivers/net/ethernet/cadence/macb.c:793:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  drivers/net/ethernet/cadence/macb.c:796:2: warning: large integer implicitly truncated to unsigned type [-Woverflow]

Use -1 insted of ~0UL, as done in other places in the driver,
to silence these warnings.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
---
 drivers/net/ethernet/cadence/macb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

David Laight Oct. 23, 2012, 8:21 a.m. UTC | #1
> When building macb on x86_64 the following warnings show up:
>   drivers/net/ethernet/cadence/macb.c: In function macb_interrupt:
>   drivers/net/ethernet/cadence/macb.c:556:4: warning: large integer implicitly truncated to unsigned type [-Woverflow]
...
> -			macb_writel(bp, IDR, ~0UL);
> +			macb_writel(bp, IDR, -1);

Seems wrong to fix an error with an unsigned value
by using -1.

	David
David Miller Oct. 23, 2012, 8:48 a.m. UTC | #2
From: "David Laight" <David.Laight@ACULAB.COM>
Date: Tue, 23 Oct 2012 09:21:11 +0100

>> When building macb on x86_64 the following warnings show up:
>>   drivers/net/ethernet/cadence/macb.c: In function macb_interrupt:
>>   drivers/net/ethernet/cadence/macb.c:556:4: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> ...
>> -			macb_writel(bp, IDR, ~0UL);
>> +			macb_writel(bp, IDR, -1);
> 
> Seems wrong to fix an error with an unsigned value
> by using -1.

-1 is equally an unsigned value of all 1's and completely legitimate.
The correction being made here is one of size not signedness.
Lothar Waßmann Oct. 23, 2012, noon UTC | #3
Hi,

David Miller writes:
> From: "David Laight" <David.Laight@ACULAB.COM>
> Date: Tue, 23 Oct 2012 09:21:11 +0100
> 
> >> When building macb on x86_64 the following warnings show up:
> >>   drivers/net/ethernet/cadence/macb.c: In function macb_interrupt:
> >>   drivers/net/ethernet/cadence/macb.c:556:4: warning: large integer implicitly truncated to unsigned type [-Woverflow]
> > ...
> >> -			macb_writel(bp, IDR, ~0UL);
> >> +			macb_writel(bp, IDR, -1);
> > 
> > Seems wrong to fix an error with an unsigned value
> > by using -1.
> 
> -1 is equally an unsigned value of all 1's and completely legitimate.
> The correction being made here is one of size not signedness.
> 
You could use '~0' (without the 'UL').


Lothar Waßmann
Joachim Eastwood Oct. 23, 2012, 5:20 p.m. UTC | #4
On Tue, Oct 23, 2012 at 2:00 PM, Lothar Waßmann <LW@karo-electronics.de> wrote:
> Hi,
>
> David Miller writes:
>> From: "David Laight" <David.Laight@ACULAB.COM>
>> Date: Tue, 23 Oct 2012 09:21:11 +0100
>>
>> >> When building macb on x86_64 the following warnings show up:
>> >>   drivers/net/ethernet/cadence/macb.c: In function macb_interrupt:
>> >>   drivers/net/ethernet/cadence/macb.c:556:4: warning: large integer implicitly truncated to unsigned type [-Woverflow]
>> > ...
>> >> -                  macb_writel(bp, IDR, ~0UL);
>> >> +                  macb_writel(bp, IDR, -1);
>> >
>> > Seems wrong to fix an error with an unsigned value
>> > by using -1.
>>
>> -1 is equally an unsigned value of all 1's and completely legitimate.
>> The correction being made here is one of size not signedness.
>>
> You could use '~0' (without the 'UL').

The reason for choosing '-1', as noted in patch description, is that
it already appears in a couple of other places in the driver. So I
though it would nice to be consistent.

regards
Joachim Eastwood
diff mbox

Patch

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 6c84a11..6a4f499 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -553,7 +553,7 @@  static irqreturn_t macb_interrupt(int irq, void *dev_id)
 	while (status) {
 		/* close possible race with dev_close */
 		if (unlikely(!netif_running(dev))) {
-			macb_writel(bp, IDR, ~0UL);
+			macb_writel(bp, IDR, -1);
 			break;
 		}
 
@@ -789,11 +789,11 @@  static void macb_reset_hw(struct macb *bp)
 	macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
 
 	/* Clear all status flags */
-	macb_writel(bp, TSR, ~0UL);
-	macb_writel(bp, RSR, ~0UL);
+	macb_writel(bp, TSR, -1);
+	macb_writel(bp, RSR, -1);
 
 	/* Disable all interrupts */
-	macb_writel(bp, IDR, ~0UL);
+	macb_writel(bp, IDR, -1);
 	macb_readl(bp, ISR);
 }