Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp973695ybt; Wed, 17 Jun 2020 19:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1lgQxlx3NBPKjdHYkGx/fX4iFZuI5Ik2SRaDqhtrjTHKA8Q3Dj0ehbvmEyMftX6ZsHC4F X-Received: by 2002:a17:906:365a:: with SMTP id r26mr1925117ejb.466.1592447669005; Wed, 17 Jun 2020 19:34:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592447668; cv=none; d=google.com; s=arc-20160816; b=n1BpwNm7U7ufMeaVC2OuVODPVeKhwcqffEP/qVTCleoc38v7qu2Rpeni1qnL5tNkQV ePIx9DoB1Dro8eNylTtOF1+yYgzejxB2+QDRmI2rlJzl5M4AXwTaV2w4lfAEd/Lqvb92 fEKgPoocNjLDiRO0FAwj/GmRsVmR5JCIDo37rGTbyWbkUF542avVpdC95kzwmyMGtVbN cWYiB+Kd1tU0MJv4IZQvENfMZS3NOPQ+B6NSvO8FXBee1Drrmngg2XQhrzTVbJnOeHXS H6Kgm6UbLg7LRiZMKHwHbBNoh1gZjqonr3dutu7j/Y42cYajpCjOs5NnFYYZN/CppW08 9ihA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sycbI1kMLpA5HRo7KwhiVnv+CMOO7q8A1zMKnQKrDzo=; b=NgxkbobdGzPCBlulaqMBABDtLq8uak13rmg8LuShD6oTGrlTd07O8pT3SV1qzjLaK5 qdYhlwqaKhSbeDXFYlZwe+WOKBcI8jfaa9zoOTs8DTINbn/sNFoGkc9D+vQ8OMXH3EuJ UkMKdQVyJH6pzyIrKe1GGYFYZlqGDqxzGj9UXILd2VKYpwEelsxB1XmC9EfGxZGFW5OG 6CWy3mre42w9dP76OXrfMyyJ+zlRlRU5zd61UE/la6n/v3FqsEeTEEYB1i48901ekPKZ oiiBsdY/6rErM6lr6sG+Ecn+Jf5UtnorP/Sya4dMPKn4wJsmKRO6W3OMztRUjbrhSDT8 6OOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cs1SkbEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si1082808ejy.164.2020.06.17.19.34.07; Wed, 17 Jun 2020 19:34:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Cs1SkbEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387421AbgFRCcB (ORCPT + 99 others); Wed, 17 Jun 2020 22:32:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:45332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728929AbgFRBPW (ORCPT ); Wed, 17 Jun 2020 21:15:22 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1136D21BE5; Thu, 18 Jun 2020 01:15:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442921; bh=UV6/2/zCAHdwmU09mq1h/o43ERhJ/dSeZzEV/wzr3cw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cs1SkbEKnNOiU91WllzhrFU51BSOIOzwqj3kclTsgrLGBcU8vWRvWbZoatKhmEh5p ZebD5Rlnj/ZyaeBYhDge2l6nVoh2Qx4vBRWenM1R0V9AfBJVe/aki/na5OG71MB7cj 3jMwosxOEnoSsWThZkFLCw+AaDQ0vnTiDsWnJXN0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Andrew Morton , Christian Brauner , Andy Shevchenko , Rasmus Villemoes , Josh Poimboeuf , Nick Desaulniers , Linus Torvalds , Sasha Levin , clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.7 337/388] include/linux/bitops.h: avoid clang shift-count-overflow warnings Date: Wed, 17 Jun 2020 21:07:14 -0400 Message-Id: <20200618010805.600873-337-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit bd93f003b7462ae39a43c531abca37fe7073b866 ] Clang normally does not warn about certain issues in inline functions when it only happens in an eliminated code path. However if something else goes wrong, it does tend to complain about the definition of hweight_long() on 32-bit targets: include/linux/bitops.h:75:41: error: shift count >= width of type [-Werror,-Wshift-count-overflow] return sizeof(w) == 4 ? hweight32(w) : hweight64(w); ^~~~~~~~~~~~ include/asm-generic/bitops/const_hweight.h:29:49: note: expanded from macro 'hweight64' define hweight64(w) (__builtin_constant_p(w) ? __const_hweight64(w) : __arch_hweight64(w)) ^~~~~~~~~~~~~~~~~~~~ include/asm-generic/bitops/const_hweight.h:21:76: note: expanded from macro '__const_hweight64' define __const_hweight64(w) (__const_hweight32(w) + __const_hweight32((w) >> 32)) ^ ~~ include/asm-generic/bitops/const_hweight.h:20:49: note: expanded from macro '__const_hweight32' define __const_hweight32(w) (__const_hweight16(w) + __const_hweight16((w) >> 16)) ^ include/asm-generic/bitops/const_hweight.h:19:72: note: expanded from macro '__const_hweight16' define __const_hweight16(w) (__const_hweight8(w) + __const_hweight8((w) >> 8 )) ^ include/asm-generic/bitops/const_hweight.h:12:9: note: expanded from macro '__const_hweight8' (!!((w) & (1ULL << 2))) + \ Adding an explicit cast to __u64 avoids that warning and makes it easier to read other output. Signed-off-by: Arnd Bergmann Signed-off-by: Andrew Morton Acked-by: Christian Brauner Cc: Andy Shevchenko Cc: Rasmus Villemoes Cc: Josh Poimboeuf Cc: Nick Desaulniers Link: http://lkml.kernel.org/r/20200505135513.65265-1-arnd@arndb.de Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- 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 9acf654f0b19..99f2ac30b1d9 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -72,7 +72,7 @@ static inline int get_bitmask_order(unsigned int count) static __always_inline unsigned long hweight_long(unsigned long w) { - return sizeof(w) == 4 ? hweight32(w) : hweight64(w); + return sizeof(w) == 4 ? hweight32(w) : hweight64((__u64)w); } /** -- 2.25.1