From patchwork Tue Jun 23 19:56:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191590 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp1360593ecs; Tue, 23 Jun 2020 14:13:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6SOepxo4CYvJZCX1I0GKWgewI8CiHvUitvMfIQ795dvvEz8JUgOIN0yi48oO6RH+2n5af X-Received: by 2002:aa7:cd4b:: with SMTP id v11mr24695181edw.356.1592946807138; Tue, 23 Jun 2020 14:13:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592946807; cv=none; d=google.com; s=arc-20160816; b=lOpWc+Gk2dFe+EJSMQ+Tmerdg96WblD5FAOUdg7rrQRPaAYw4Z5bxJ0Tzahd0q4/d0 /xNFiKA+sh9ttYmS+RsXCfSrXco4TfY/G7CEYjjzOouhfi6yF33ZgXDA+pGaUqzY9gTH TZwRn/qj/pacI77/6vGQstKGhteAnAH+qO/P7dl/j1BBLBRJdty+UO+LPS9UclI8mE1V J2EgJAGDvYAhcokQHX5QaEiIV7WklMvwEirKMZVj2LZ/o7kGIfyuWsLMO/DwobZKel+t CU43BpWC6knsa112rgr+U5Eoj4CxJVrzd+TnZfn7UPkiNUS0tg4Q7z40QsEz8qJWOR0b +cmw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BhFy95w+vwTZ+GbOfMfdkhMSDepkE5JWjw3GEEh4JpM=; b=qvoeFb3dAi4ugUIJK0cIV+PoLgE9XfF98LmZW729eMz4zJTjl7J2iYnPsxCm3sxdpQ iTMso0RRHhwn03I9tySn7yU4DVjWPHh74UkSlGs2zAayaEBxdczcQkD8X+QZsouBknhB cICxw3tatC79ERmGrP6tQMAfarIq7ugJ+wIF5CNNOh3ff6CVOL3OL3XToUU7tPy8Fd0V 98JNg5H8kpwXNViXcn5/TlHUlX3sXIbAmwBWkJdEuoIQReZKPoCgfUrJV8L62uHwR8MB IpoxkDbzdtwwGlkRnv0VpU+dmTMKPRlZzwLaazrj+vXsEXiFYItEuY4gbtAEXMVN4ltr BLMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=goO43waX; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f13si3159180eje.212.2020.06.23.14.13.26; Tue, 23 Jun 2020 14:13:27 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=goO43waX; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391503AbgFWVNZ (ORCPT + 15 others); Tue, 23 Jun 2020 17:13:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:50788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391133AbgFWUaa (ORCPT ); Tue, 23 Jun 2020 16:30:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F3AE720702; Tue, 23 Jun 2020 20:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944230; bh=rDIiLRb8X8P1FglrJqtivd3kIsMnTBfZVtrE4QbREb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=goO43waX0V3lAvlKE9CvFVJpJtBDnfGq3SuA0+Gv0bKyki0spLNzN3sIFljw/Gmet hDy+G0LSdJIm4y+s7uS3udiNPZ4vqXW3rgG96rhLNJh+yEzGl9wWoTNpAYxPgw8u2l 32KSyMVQK6wPF3k9KJgxEsuftx6FdH/7szocE/PU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Andrew Morton , Christian Brauner , Andy Shevchenko , Rasmus Villemoes , Josh Poimboeuf , Nick Desaulniers , Linus Torvalds , Sasha Levin Subject: [PATCH 5.4 223/314] include/linux/bitops.h: avoid clang shift-count-overflow warnings Date: Tue, 23 Jun 2020 21:56:58 +0200 Message-Id: <20200623195349.586279778@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.25.1 diff --git a/include/linux/bitops.h b/include/linux/bitops.h index c94a9ff9f082e..4f0e62cbf2ffe 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -57,7 +57,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); } /**