Message ID | 1350931534-8416-2-git-send-email-manabian@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> 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
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.
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
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 --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); }
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(-)