From patchwork Wed Aug 2 22:51:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9877845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C05FB60360 for ; Wed, 2 Aug 2017 22:54:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B10D627853 for ; Wed, 2 Aug 2017 22:54:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A10DE27F8E; Wed, 2 Aug 2017 22:54:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D0D027853 for ; Wed, 2 Aug 2017 22:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=aw64cBnei2slakmJIjht2xx18WjPIMioSy/xL0La170=; b=uyW UrKHYZn/mcdnhFj3CXP0oiDaftCrbeGIjgXSo9QxRKCPDdbJlETPnoyfbMroG/YXodk2R5DX5liqa BJE5io4XVwjoaAS58YO/MVf1CXytWXhWuxpDpEhP6Xeh8qw0jrlx2a5vQ4NnjTe0WfjBOEZwAlzlU diYXlg6Cd4ri21z/6mmctaG1MoX/ezdSEdq7cynOkMsnX8ebdOkQdMtaTzukgIEsW5rHdaS6d9Mn6 Pa8+4/gfbL6AfCGllKOcbzqRXlvFKJWFaDxmyYQH4by7HDd7qnwuf8xM0n2X0wKvnDaxl8C8Ktm3g /lc5Ay4szUB2xpktOzcqtUTPGTS+Iuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dd2Vf-0000nb-93; Wed, 02 Aug 2017 22:52:59 +0000 Received: from mail-pg0-f44.google.com ([74.125.83.44]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dd2Vb-0000mL-Gm for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2017 22:52:57 +0000 Received: by mail-pg0-f44.google.com with SMTP id y129so26664876pgy.4 for ; Wed, 02 Aug 2017 15:52:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gz3fAvbeYvLyLgZtm2U7Gls1YPLzZ+HRtSsWrvTYxXU=; b=HP7bH3qNABPJA2QewHXs1KnVPBwCe1d2brlE++TZ3sejZ5pUTAZ/WVwyPRkOgTVaDb 8b5mqHNgVK6Fg1hya9D+Y99GAx5QSS/WSpX0AajrjW5ZWfONvsAww7VQJMiVzdV79Vt/ pXSpWo2B7ssMBbENVk5u+wj1yxGKUV+fVsnGqycCSajiMmeE6MRGT37pET0VfT0L2hs2 Tu5XqCHbqiv2F0wgMDx0xXBB4D5/OGVj+1j+cpE4MqitFtOQIj/DrDmacIKOadIjKQGa o4BCJI4WbG9LSljrwtQsd/4OytYkK1Qe135VqPOaATj6k3vfBvACZhOnBIdAZgrVKa90 ZI6w== X-Gm-Message-State: AIVw110CkThAfisvyewKOtWe9080OqPAP6FNh5CCwEI5xcbmJRLzZZxe qe71L9I5AzZ2ZG8t X-Received: by 10.98.19.78 with SMTP id b75mr23542247pfj.212.1501714354218; Wed, 02 Aug 2017 15:52:34 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.112.49]) by smtp.gmail.com with ESMTPSA id t17sm65412103pge.55.2017.08.02.15.52.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Aug 2017 15:52:33 -0700 (PDT) From: Matthias Kaehlcke To: zijun_hu , Andrew Morton , Catalin Marinas , Will Deacon , Mark Rutland , Laura Abbott Subject: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Date: Wed, 2 Aug 2017 15:51:58 -0700 Message-Id: <20170802225159.159536-1-mka@chromium.org> X-Mailer: git-send-email 2.14.0.rc1.383.gd1ce394fe2-goog X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170802_155255_634040_CE4467BE X-CRM114-Status: GOOD ( 10.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, Greg Hackmann , Doug Anderson , Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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)))) #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);