Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751247AbdHCNZ1 (ORCPT ); Thu, 3 Aug 2017 09:25:27 -0400 Received: from mail-cys01nam02on0084.outbound.protection.outlook.com ([104.47.37.84]:22688 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751083AbdHCNZ0 (ORCPT ); Thu, 3 Aug 2017 09:25:26 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@cavium.com; Date: Thu, 3 Aug 2017 16:24:56 +0300 From: Yury Norov To: Matthias Kaehlcke Cc: zijun_hu , Andrew Morton , Catalin Marinas , Will Deacon , Mark Rutland , Laura Abbott , Nick Desaulniers , linux-kernel@vger.kernel.org, Greg Hackmann , Doug Anderson , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Message-ID: <20170803132456.mwrt6yspkbqxcffw@yury-thinkpad> References: <20170802225159.159536-1-mka@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170802225159.159536-1-mka@chromium.org> User-Agent: NeoMutt/20170113 (1.7.2) X-Originating-IP: [41.141.206.184] X-ClientProxiedBy: HE1PR09CA0081.eurprd09.prod.outlook.com (10.174.50.153) To SN1PR07MB2126.namprd07.prod.outlook.com (10.164.46.156) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c84da7ba-8dc6-409b-fea9-08d4da73187c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:SN1PR07MB2126; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2126;3:ay62Xpilashtn8+dO/st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/qQpvtZRzeF3yfs0gQdS+Z18nCEqjlqJCmzRU4fhyEckc9O36ZZf9cyj4OpcUcr/mD5RQu5qSPtcwWdJ04S6VUpcnCOHC1SiZV+AnnMUx9bW7BHZijDeqtdbbBpGCdHhUs6YH+HZHn1qQbnEFUuySdRugSqtfpqQnFn0QeiWZbOJ2CGnJuBkc5TykbiMq0HqYYNxIxE5gDlHzFtIYHwrPfPk1KAEFU4ukbIWzTfF51TrsAG8oHqefHZK1xsA5SccaZs/+tyOptE7pZo9A1rGfIFCZwXC2LMkqwjK1OkcGutZ0CRw8c/kN+r/T4X5Ka0FL2Tb9zr08CuQ7aYdiYAN9qvqJU1q/txpvBj93SgBZBFSMGPen/mbv+MQ04MBHMq0G8xljyu5dK/5HuvwO5mFmLZT9j3NkhNyLXO3uj5WYZc+uVM=;4:ESI1E73wCdAkPGrQqVyJeOudVuxMKnbZ8PnDjOJSnXPIwcDVu5Wo/VSch+J/0rjR52XHEjRrDb6p4Z7Yji+4ioRUpHnYEEQUAr9p7oRTuTCMxceKC4Ux1AAiDbZAf1uVuuyS50aHbcxAyUPk3M3rXLUByuNHHbsBEtWqMS5xt9s5U1AxugVMeKspWa+5EpQdunGUeMQ43sGf0Sbz5PcGzATZjMjp5iUHoEFiK92u9NCXu767eFKMuaAw4G4fdmmaZL9lIocqyeEH2vjlroRVBWigM9KRVQolWbZi4oT1CGY= X-Exchange-Antispam-Report-Test: UriScan:(258649278758335); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(100000703101)(100105400095)(93006095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123558100)(20161123560025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SN1PR07MB2126;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SN1PR07MB2126; X-Forefront-PRVS: 03883BD916 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(7370300001)(4630300001)(6009001)(6069001)(39850400002)(39450400003)(39410400002)(39400400002)(39840400002)(199003)(24454002)(189002)(47776003)(66066001)(305945005)(81166006)(2906002)(81156014)(50986999)(76176999)(54356999)(966005)(53936002)(4326008)(25786009)(54906002)(6306002)(9686003)(101416001)(10646004)(83506001)(68736007)(478600001)(8676002)(4001350100001)(7736002)(33646002)(42186005)(189998001)(1720100001)(105586002)(33716001)(229853002)(97736004)(5001810100001)(6486002)(76506005)(2950100002)(1076002)(72206003)(42882006)(6916009)(6666003)(6496005)(50466002)(38730400002)(110136004)(7416002)(7350300001)(6246003)(106356001)(5660300001)(23726003)(3846002)(6116002)(10916006)(3486003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2126;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;SN1PR07MB2126;23:9kP8RxW76DakQl8kYDLhFiG/2iMVuwHZmWpPlvBu5?= =?us-ascii?Q?e1cF3KNj16rWiho+eYGmx9LeNFQUTodiZQo2bmQa858RkcL78sKOKcWd3ell?= =?us-ascii?Q?Q4xDaiX0FyXvx0ZBuQDdZ1+XBMr5UIx8FxB6/O+s6/PtAXPFJhvth5DlqqOt?= =?us-ascii?Q?r5IDiYz946vM4OdG0lEky9E/Vo5YSqWjSOEaCHcph1zfyRCQEM03JWK4IgRx?= =?us-ascii?Q?oxamVEUyUpzsrHFseiLru7TROCdRLiGWvEks9Ql7Ks9NB83hDinnayuJO2tD?= =?us-ascii?Q?2W5gtgzU+lchu0aAwfIM55B0Lq0+ta/Jobz6+v19VsdrlOfL6JbrXkek7Jaq?= =?us-ascii?Q?/oJ6nSi466HHJ5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MHoEujXP/AoXt+sAw=;7:R+P2GGHoLR/2/2IxJHnGmK0U9Gns6QkUOlwxbRPHV4M33Bac8oi1EVMoIsJQi4ZMShr2x9q/9x+qy+O8CrAl8A2/Ga+/gREP6zqyEDzR97OY7oSRcKkuOrzqz4qJIZ43/O5XRLtLH7PMdaQjy6UolyheLCLZYTDlTpvJvKSmuZp+6fB4BSsPhskyMUgo8OBFfZEQ8OelIlvV/j0VpBfy5EZ4WPDhCbuf0oZiNSDObvc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2017 13:25:19.5676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2126 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1326 Lines: 36 On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote: > GENMASK_ULL performs a left-shift of (~0ULL), which technically > results in an integer overflow. clang raises a warning about > this if the overflow occurs in a preprocessor expression. To > avoid the overflow first perform a right-shift to clear the > bits that are shifted out. > > Signed-off-by: Matthias Kaehlcke > --- > include/linux/bitops.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/bitops.h b/include/linux/bitops.h > index a83c822c35c2..21dfe63001e3 100644 > --- a/include/linux/bitops.h > +++ b/include/linux/bitops.h > @@ -22,7 +22,7 @@ > (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) Once you touche GENMASK_ULL, why not to fix also GENMASK. > > #define GENMASK_ULL(h, l) \ > - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) > + ((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) > > extern unsigned int __sw_hweight8(unsigned int w); > extern unsigned int __sw_hweight16(unsigned int w); > -- > 2.14.0.rc1.383.gd1ce394fe2-goog > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel