Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp10406ybt; Tue, 23 Jun 2020 13:56:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOiC/lSomaFrwviuTFKNCD+DZ8/tyminza5woI2eT/ho0d6tqyIs3EposcHK1ENAihAeh2 X-Received: by 2002:aa7:d693:: with SMTP id d19mr19453016edr.297.1592945781117; Tue, 23 Jun 2020 13:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945781; cv=none; d=google.com; s=arc-20160816; b=d2LgGrFc2MZ11oEobmkzlQO903Yc2pvPnt8/UKjeGZf6BPiHNHye88Wqqv3/8Wfryj xGyHoHU17YtK/BF1g6h2EzlX8R5qMZy3TI9UHYvJi4OI8tJBMoejwuSc6V4jzrYdWC1u o19Mz4EQBK8IPqqj3Hm0v0OefXYUrcbMRewFrkrK8M7hdlJXlQBSj3TjoLzyrvfmYUP7 e3FI6kk6/Bn7YAn366sJs27AFW1+kXYahJZypUNqJvcTQYZ+WHiR/ajGMx/GgcjR1ENX 4LVOhYMdVpsmeT8k4zb8palnNUMgJES/DmMuK62RD6KZbGqLX4SoW7kKt3Z7DRjoSmHu dovw== 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=v8oNOVvr3+BjxY9JHwHWMlGFKpdU5IvT2+Lj5wCOJwc=; b=qYnSdETwTpeei+1aX4mQ8HYkk7AeJUmc8R4mJ8OW5uAZ+pazGVjFfsAq5fttgqNejx xj2v+5xOPoNrRt2VWpJiNCZxAo78d7BqKW+qYAyMwlygcEQOfkVUiUgZ1WA/SqKA/UEy X4Dd0LSaTARewJPssySvNF67wDoWSHY+KWzQVI7h0FELknY66CL1SwBqdY7lM0znxibi ZgQ0AWUyJAL0I83ZeXxDh4JEaQC4ggwmO4F1zGCPOFAJqqs93X7sbZ6NEfHjTawwEw1B 3+b476VGcN+JVZdbiIcFWNETjxNXZubfcqh0w/qLmYnVYllbWoTmhQCmTfAfOGQ5xXA+ gHvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OOMnjAoH; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si13101723edv.438.2020.06.23.13.55.58; Tue, 23 Jun 2020 13:56:21 -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=OOMnjAoH; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404120AbgFWUwh (ORCPT + 99 others); Tue, 23 Jun 2020 16:52:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:45706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392646AbgFWUrW (ORCPT ); Tue, 23 Jun 2020 16:47:22 -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 AAB1521548; Tue, 23 Jun 2020 20:47:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945242; bh=rUZwV8m1SsRpjOZ7LNVk9MSgEy+9ANrwiDmXq8bLAe4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OOMnjAoHDtHILN1NP7XaE8+0JnJ9A6Wr7vWKCNcqXD6WnjICpkEh8lgcusB487sie AJjGDnhAIjXi/RuSeNtQjCZ1wcJfKXCc4yL3EjPsxhQS3OX2XaNuc0ATcjc+D21DMX o30QZQ4kCZpAgDIRfSNLDEkzp5YASKpgUg+O33G4= 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 4.14 094/136] include/linux/bitops.h: avoid clang shift-count-overflow warnings Date: Tue, 23 Jun 2020 21:59:10 +0200 Message-Id: <20200623195308.393610606@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 c51574fab0b00..00dcb1bad76b8 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -50,7 +50,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