From patchwork Tue Jun 23 19:59:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 191572 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp1347456ecs; Tue, 23 Jun 2020 13:52:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkczG9hlWX7AzI9eobpld8VMePG9RJG6uovH3F9fUYZW3esNzNOeoky6LJwdqoB3zDS5vD X-Received: by 2002:aa7:dcc8:: with SMTP id w8mr4719277edu.305.1592945566799; Tue, 23 Jun 2020 13:52:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592945566; cv=none; d=google.com; s=arc-20160816; b=IvGFG/kcw1Ckn+W8NhKcXqyJAs+9J05MvbbAFdSPkSko8A91L11JoiZeEex/8smupR xa2YlyNLnjT6QLiDvBAcJTOxpo+d/UfEQoNlwFFZ2gJ4KL189bOdA0m2smpkw30jij4A EJHttzOSApTomPduWkrSPnlj4ZxsrDxOLgjljxFU5sS95adXtgn22zT0+yRlUHbZfkyP o/6/F3Q+0G8UcZBPYdKKzBdeEmBJtYqnKDOSsFwbDQb+kbt2kckT9CaLpBUbenKnIULA h5DDIIXymOGscTNkSOKf9sGZPCpAyOtnwY4BFddw/39pYRaH1Y6lOuIYHjs9ot5hpzct g/rQ== 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=b+ho19FH0hL/904jwkAJq54mt33XtAuoD79KKsz15/Mi/v/N0zlJuZrTyuksJ3G2mR cY/rKo1tS1W3wUj8/SnCLuXqBlyVPIhOoT7fJ7LyonU72q8WL7zvOpLPR5jBVqgtFKnH JL3/jW1ZhUXEGfIT08xeNA4IrTL2rteGW9siBcjps2f3q0QKRtRpGShCmnLMvh+aHXRI Ljh/O4A7fGNzTvEXBvzLGzjddus64t2rMQMLL3DmT3UJ2TzyR1oFeDeCVKZJLrltrnEU abr2+qp9sLNo/LpfO1SDFUNic6qVXWMmet4rE6cSIVkP7E66IA54Ms420kjVUY/fChGn OxiA== 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 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 lc19si141862ejb.584.2020.06.23.13.52.46; Tue, 23 Jun 2020 13:52:46 -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=OOMnjAoH; 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 S2404041AbgFWUwg (ORCPT + 15 others); Tue, 23 Jun 2020 16:52:36 -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 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 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); } /**