From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753539AbbKMHww (ORCPT ); Fri, 13 Nov 2015 02:52:52 -0500 Received: from smtprelay0197.hostedemail.com ([216.40.44.197]:56848 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752126AbbKMHwu (ORCPT ); Fri, 13 Nov 2015 02:52:50 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 50,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1431:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2553:2561:2564:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:6261:7903:8985:9025:10004:10400:10848:11026:11232:11473:11658:11914:12043:12438:12517:12519:12555:12740:13069:13311:13357:14096:14097:14659:21080:30034:30054:30080:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: nest97_1874b5b7bf35b X-Filterd-Recvd-Size: 3180 Message-ID: <1447401166.6012.2.camel@perches.com> Subject: Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning From: Joe Perches To: Geert Uytterhoeven , Arnd Bergmann Cc: "linux-arm-kernel@lists.infradead.org" , David Miller , "netdev@vger.kernel.org" , mathieu@codeaurora.org, "linux-kernel@vger.kernel.org" , Giuseppe Cavallaro Date: Thu, 12 Nov 2015 23:52:46 -0800 In-Reply-To: References: <4391788.dtYArQ4mVi@wuerfel> <20151112.122528.1794206832971213176.davem@davemloft.net> <3729464.5X0HBxzvx5@wuerfel> <3825178.3luTQFAgny@wuerfel> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.16.5-1ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2015-11-13 at 08:37 +0100, Geert Uytterhoeven wrote: > On Thu, Nov 12, 2015 at 10:03 PM, Arnd Bergmann > wrote: > > 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)) > > > > This is a result of the type conversion rules in C, when we take > > the > > logical OR of multiple different types. In particular, we have > > and unsigned long > > > > QSGMII_PHY_CDR_EN == BIT(0) == (1ul << 0) == > > 0x0000000000000001ul > > > > and a signed int > > > > 0xC << QSGMII_PHY_TX_DRV_AMP_OFFSET == 0xc0000000 > > > > which together gives a signed long value > > > > 0xffffffffc0000001l > > > > and when this is passed into a function that takes an unsigned int > > type, > > gcc warns about the signed overflow and the loss of the upper 32 > > -bits that > > are all ones. > > > > This patch adds 'ul' type modifiers to the literal numbers passed > > in > > here, so now the expression remains an 'unsigned long' with the > > upper > > bits all zero, and that avoids the signed overflow and the warning. > > FWIW, the 64-bitness of BIT() on 64-bit platforms is also causing > subtle > warnings in other places, e.g. when inverting them to create bit > mask, cfr. > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commi > t/?id=a9efeca613a8fe5281d7c91f5c8c9ea46f2312f6 > > Gr{oetje,eeting}s, I still think specific length BIT macros can be useful. https://lkml.org/lkml/2015/10/16/852 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Perches Subject: Re: [PATCH v2] stmmac: avoid ipq806x constant overflow warning Date: Thu, 12 Nov 2015 23:52:46 -0800 Message-ID: <1447401166.6012.2.camel@perches.com> References: <4391788.dtYArQ4mVi@wuerfel> <20151112.122528.1794206832971213176.davem@davemloft.net> <3729464.5X0HBxzvx5@wuerfel> <3825178.3luTQFAgny@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Cc: "linux-arm-kernel@lists.infradead.org" , David Miller , "netdev@vger.kernel.org" , mathieu@codeaurora.org, "linux-kernel@vger.kernel.org" , Giuseppe Cavallaro To: Geert Uytterhoeven , Arnd Bergmann Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Fri, 2015-11-13 at 08:37 +0100, Geert Uytterhoeven wrote: > On Thu, Nov 12, 2015 at 10:03 PM, Arnd Bergmann > wrote: > > 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)) > > > > This is a result of the type conversion rules in C, when we take > > the > > logical OR of multiple different types. In particular, we have > > and unsigned long > > > > QSGMII_PHY_CDR_EN == BIT(0) == (1ul << 0) == > > 0x0000000000000001ul > > > > and a signed int > > > > 0xC << QSGMII_PHY_TX_DRV_AMP_OFFSET == 0xc0000000 > > > > which together gives a signed long value > > > > 0xffffffffc0000001l > > > > and when this is passed into a function that takes an unsigned int > > type, > > gcc warns about the signed overflow and the loss of the upper 32 > > -bits that > > are all ones. > > > > This patch adds 'ul' type modifiers to the literal numbers passed > > in > > here, so now the expression remains an 'unsigned long' with the > > upper > > bits all zero, and that avoids the signed overflow and the warning. > > FWIW, the 64-bitness of BIT() on 64-bit platforms is also causing > subtle > warnings in other places, e.g. when inverting them to create bit > mask, cfr. > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commi > t/?id=a9efeca613a8fe5281d7c91f5c8c9ea46f2312f6 > > Gr{oetje,eeting}s, I still think specific length BIT macros can be useful. https://lkml.org/lkml/2015/10/16/852 From mboxrd@z Thu Jan 1 00:00:00 1970 From: joe@perches.com (Joe Perches) Date: Thu, 12 Nov 2015 23:52:46 -0800 Subject: [PATCH v2] stmmac: avoid ipq806x constant overflow warning In-Reply-To: References: <4391788.dtYArQ4mVi@wuerfel> <20151112.122528.1794206832971213176.davem@davemloft.net> <3729464.5X0HBxzvx5@wuerfel> <3825178.3luTQFAgny@wuerfel> Message-ID: <1447401166.6012.2.camel@perches.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Fri, 2015-11-13 at 08:37 +0100, Geert Uytterhoeven wrote: > On Thu, Nov 12, 2015 at 10:03 PM, Arnd Bergmann > wrote: > > 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)) > > > > This is a result of the type conversion rules in C, when we take > > the > > logical OR of multiple different types. In particular, we have > > and unsigned long > > > > QSGMII_PHY_CDR_EN == BIT(0) == (1ul << 0) == > > 0x0000000000000001ul > > > > and a signed int > > > > 0xC << QSGMII_PHY_TX_DRV_AMP_OFFSET == 0xc0000000 > > > > which together gives a signed long value > > > > 0xffffffffc0000001l > > > > and when this is passed into a function that takes an unsigned int > > type, > > gcc warns about the signed overflow and the loss of the upper 32 > > -bits that > > are all ones. > > > > This patch adds 'ul' type modifiers to the literal numbers passed > > in > > here, so now the expression remains an 'unsigned long' with the > > upper > > bits all zero, and that avoids the signed overflow and the warning. > > FWIW, the 64-bitness of BIT() on 64-bit platforms is also causing > subtle > warnings in other places, e.g. when inverting them to create bit > mask, cfr. > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commi > t/?id=a9efeca613a8fe5281d7c91f5c8c9ea46f2312f6 > > Gr{oetje,eeting}s, I still think specific length BIT macros can be useful. https://lkml.org/lkml/2015/10/16/852