From patchwork Tue Jun 23 19:55:26 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: 191607 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp1370607ecs; Tue, 23 Jun 2020 14:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwUEi3pAs+jmo4EY6Y70g6NmDVuemkrgTPyIC3lFgYUCiwUjQoa0XEkHOA/jj3Ayg2ohmL X-Received: by 2002:a17:906:4c97:: with SMTP id q23mr5214752eju.534.1592947851791; Tue, 23 Jun 2020 14:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592947851; cv=none; d=google.com; s=arc-20160816; b=T6Ydd5JyCtDZJt3WBB17wRa86l5wajF5I+39QGk8oAnZFsBD92H5UY0h8UyfN4SEH3 9lK5rk01Xo37YeW2qdlnFRLeAkqAqjykExQXZwWzfO2Q5/gholGi2rjrWvhj82lyHbKx JE9NhAKVkX/G2Y8Amb222Ytqsv0RNL+3HNh09idRm6ldlASnN23y92A03wdufNeh2y5e zk+MyjYpNu/Tsob252PSjTvhyLWQWn/6mGkZjOnXazkUkvAmh96Scm4St1O85w+1/GEO gOzI1DqaC+spQ0drNFnE/jLGbQuRtRvph2O3APrDEACEJ0K7Zvwy3kd9sE+P7cX563mA mwjQ== 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=OAMuR1/1/Ut2n0b4ya51l8ttClE3USc6MaFdkkKmeBU=; b=SBt/YJfxJcJJ8RwAcdopCbyZoxvCvI+a3+pBuiZVxTSp4cpla8EJXJ6jr0CrDIu8Sh se994i3TE1RRClnih43fdw4pChO++MnZAq5T06yWHZmrqRusQXLtgjd00ZyC/8vZ25cy ITEsIawQdoOkvmCM+05e+TS0t3cjmjIh3efNpxJPRF6Or1gVMydRgHN6D5KYfGcte+LE UDj7EiVypm9SffYuY0uBzX6UuHT2QCQYxj7D7zPnzAFrAvHr5pD0yH39pfwiaHwxQ3e2 de/+8h6rMZXeWfwoKSZrfTPV20RFRyFBswBrHxPWtN6CaU3oSd1lBLOqqW0tJA9TVWdu MG1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tr60YAe4; 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 du12si16387407ejc.441.2020.06.23.14.30.51; Tue, 23 Jun 2020 14:30:51 -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=tr60YAe4; 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 S2388570AbgFWV3t (ORCPT + 15 others); Tue, 23 Jun 2020 17:29:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:57134 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388885AbgFWUOj (ORCPT ); Tue, 23 Jun 2020 16:14:39 -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 D0DC82137B; Tue, 23 Jun 2020 20:14:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943278; bh=PA0/KPh9VXWbprDD8v41oKM2j8WmSDeOIfzwSNvXqko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tr60YAe4WVork3P5pdTNERdYGWgxtI2Ggm0w0xUM3KPvtEYbwkRo9N1g0rLnK9DSJ SfGAjCwM7uItgaQeEuFZQdvYKyMMhLYumJucF40nDS/929Jwa2QenClzfhrgefx9Vd O2LHVVVsEWaamrQgOvH5rGwI35tNDtrlM6FcAFQs= 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.7 329/477] include/linux/bitops.h: avoid clang shift-count-overflow warnings Date: Tue, 23 Jun 2020 21:55:26 +0200 Message-Id: <20200623195423.088269827@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@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 9acf654f0b191..99f2ac30b1d9b 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); } /**