From patchwork Tue Jun 23 19:57:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 191566 Delivered-To: patch@linaro.org Received: by 2002:a92:1f07:0:0:0:0:0 with SMTP id i7csp2317545ile; Tue, 23 Jun 2020 13:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz90g7PMI58yw7IoBHcxfxHxM7Y2HHel5HnPBwvjo40p6TAL9sSy+TmKpUMgCEUiaGx5k2b X-Received: by 2002:a50:d0cc:: with SMTP id g12mr2678143edf.57.1592944820216; Tue, 23 Jun 2020 13:40:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592944820; cv=none; d=google.com; s=arc-20160816; b=xbCgQNlMpNFbcRnE0kbierfUdWqtxNEHWqz3Tq90/mkeaHj3FnDQN9hEr6Y0rp1kGP IzASHEBQosQdE564o/VjvqwsVbU1Bu7eFp1t3NqWWbl0bEOhJTB3CzWA5vdXfK2tlJd+ pRrHE0DDhBRj2PVLhi/ZEhkA89N4jDfWfnNONmaqawXL1bxWl/EpW21NUSFYEyiqEZcI Je+TM4NQYoJGqIXKcrgpcmjmuml4CBvsUkSe6mo83AE/X3gobKNyf8JR+tob2Fy3iHgK D3gXbQYIGlbpe9lf5gV5UzhhhQO3DPJic3ZHp4MOXx983leVPbzBwy5+PkDYaJ8GxRyu CSDw== 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=ch4QT4nTNGoh9mRGTx0zJLM7ty1T20BWS3k3Sh2JHQI=; b=attyrpDJ/5i1rWk7SxkyBJs8W2dNZxczHLy/UPo2hOsqpc7RdCA+ySS5apFtCIaNqT R4S81xcL61N8Deqp77cDyehi9cqRb6siX/FwAp3wzSJPKfGjvnZiaDUULyOjC21kq3h2 Y/rzJ8+u8Lxg9fjaQYqq0x64mlvuHMNtY+qRgr1Fm7DznYt7RsAmEodEcmGaC4JdbKna HEe7QzWUo7o3sLv7vOsQ9v8MFdKK6CntGGZ4ZRX1JORoWKgPZySznBZaJ9pPVtRXr3t2 YDX5xHf4b+NHC6iZ2DKQNMelkmAkF73IXN6fCG97/nH4GzKBrxKfg4hi/JoXMJl1pLox BDRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BRg3SiyE; 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 e9si6594844edn.579.2020.06.23.13.40.20; Tue, 23 Jun 2020 13:40:20 -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=BRg3SiyE; 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 S2392204AbgFWUkQ (ORCPT + 15 others); Tue, 23 Jun 2020 16:40:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:36164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390938AbgFWUkP (ORCPT ); Tue, 23 Jun 2020 16:40:15 -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 E16C021883; Tue, 23 Jun 2020 20:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944814; bh=ANj6Jzi3abtazOkw7RqmxVYzGVqP7AJKyywwP4JH8rs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRg3SiyEJJx6DCdfvBPXNyz/359LJf/ajTT6XqoDz6BD8i5mJ+WDA6P7SlcE2TKBG 0DZt6c2Yp4aaHpGSgzqLLelAIfcxJn+hP+/PJUq4auWytXZEdB4n0XfzAKg6Rhi0Uh VRz2xSfkq15rPt/XShVSSgPTR5h+TPNt5cfDvfyk= 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.19 136/206] include/linux/bitops.h: avoid clang shift-count-overflow warnings Date: Tue, 23 Jun 2020 21:57:44 +0200 Message-Id: <20200623195323.676418958@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195316.864547658@linuxfoundation.org> References: <20200623195316.864547658@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 e02cbca3cfaf0..5c1522ed2d7c7 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); } /**