Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1268121

Re: [PATCH] stmmac: avoid ipq806x constant overflow warning

From David Miller <davem@davemloft.net>
Newsgroups linux.kernel
Subject Re: [PATCH] stmmac: avoid ipq806x constant overflow warning
Date 2015-11-12 18:30 +0100
Message-ID <qu3R7-3nW-5@gated-at.bofh.it> (permalink)
References <qu0Th-1x8-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 12 Nov 2015 15:12:48 +0100

> Building dwmac-ipq806x on a 64-bit architecture produces a harmless
> warning from gcc:
> 
> stmmac/dwmac-ipq806x.c: In function 'ipq806x_gmac_probe':
> include/linux/bitops.h:6:19: warning: overflow in implicit constant conversion [-Woverflow]
>   val = QSGMII_PHY_CDR_EN |
> stmmac/dwmac-ipq806x.c:333:8: note: in expansion of macro 'QSGMII_PHY_CDR_EN'
>  #define QSGMII_PHY_CDR_EN   BIT(0)
>  #define BIT(nr)   (1UL << (nr))
> 
> The compiler warns about the fact that a 64-bit literal is passed
> into a function that takes a 32-bit argument. I could not fully understand
> why it warns despite the fact that this number is always small enough
> to fit, but changing the use of BIT() macros into the equivalent hexadecimal
> representation avoids the warning
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: b1c17215d718 ("stmmac: add ipq806x glue layer")

I've seen this warning too on x86_64 and had been meaning to look
into it, thanks for taking the initiative. :)

Moving away from using BIT() is somewhat disappointing, because we
want to encourage people to use these macros.

I think it's also easier from a driver author and auditing
perspective, you can see that something is being defined as bit X and
then check the documentation for the chip to see if bit X is correct
or not.

With the hex values there is more mental work and room for... mistakes.

Also I don't even understand the compiler's behavior, it's warning
about QSGMII_PHY_CDR_EN but if you define only that to "0x1u" it still
warns about QSGMII_PHY_CDR_EN.

The warning goes away only if you change all 5 BIT() uses.

This makes me like the change even less, something foul is going on
here and I'd rather figure out what that is than install this patch.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] stmmac: avoid ipq806x constant overflow warning Arnd Bergmann <arnd@arndb.de> - 2015-11-12 15:20 +0100
  Re: [PATCH] stmmac: avoid ipq806x constant overflow warning David Miller <davem@davemloft.net> - 2015-11-12 18:30 +0100
    Re: [PATCH] stmmac: avoid ipq806x constant overflow warning Arnd Bergmann <arnd@arndb.de> - 2015-11-12 22:00 +0100
      [PATCH v2] stmmac: avoid ipq806x constant overflow warning Arnd Bergmann <arnd@arndb.de> - 2015-11-12 22:10 +0100
        Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning David Miller <davem@davemloft.net> - 2015-11-12 22:20 +0100
        Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning Geert Uytterhoeven <geert@linux-m68k.org> - 2015-11-13 08:40 +0100
          Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning Joe Perches <joe@perches.com> - 2015-11-13 09:00 +0100
            Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning Geert Uytterhoeven <geert@linux-m68k.org> - 2015-11-13 09:10 +0100

csiph-web