From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38CC3C6FD1C for ; Tue, 14 Mar 2023 12:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbjCNMol (ORCPT ); Tue, 14 Mar 2023 08:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbjCNMoA (ORCPT ); Tue, 14 Mar 2023 08:44:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B54597FD3; Tue, 14 Mar 2023 05:43:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7E3B8B81906; Tue, 14 Mar 2023 12:43:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7AD9C433EF; Tue, 14 Mar 2023 12:43:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678797801; bh=AY/Ig6/D6B8kAit4w8uSAEvPz3sYAX7+kRJBXfUowsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVU6ng439p6BJyoms5qFXTQtMjzQZTzHFespAmfIp+lr1hAALyxT02SNauWnlAf7r 0PnyyknyMeq1s3hsxbE53FYwgAQY44lHOoocglClZE0mjBpkmVocIOUSa5VPZaihSB Buj73b03rHsw2Z4FSEJqaeZppcK6tnfnAdU+xB4I6SLY3yGeVP8GCT0YHMXey4gZzS 4mHTKBgopceHYIzgdYL1wK9frE4f1HqPykfjZMI2yTooRo6BDWxhJ+CiK3XGGPFGkZ OOdtOHUWTisRByqcm1DL8Ti3nvH5pKvZeyRmR2mORhiQXKMOVwAWGKY+6sMdKnUYhC lNh/SEwkJt34Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Karcher , Randy Dunlap , John Paul Adrian Glaubitz , Sasha Levin Subject: [PATCH AUTOSEL 6.2 11/13] sh: intc: Avoid spurious sizeof-pointer-div warning Date: Tue, 14 Mar 2023 08:43:03 -0400 Message-Id: <20230314124305.470657-11-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230314124305.470657-1-sashal@kernel.org> References: <20230314124305.470657-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Karcher [ Upstream commit 250870824c1cf199b032b1ef889c8e8d69d9123a ] GCC warns about the pattern sizeof(void*)/sizeof(void), as it looks like the abuse of a pattern to calculate the array size. This pattern appears in the unevaluated part of the ternary operator in _INTC_ARRAY if the parameter is NULL. The replacement uses an alternate approach to return 0 in case of NULL which does not generate the pattern sizeof(void*)/sizeof(void), but still emits the warning if _INTC_ARRAY is called with a nonarray parameter. This patch is required for successful compilation with -Werror enabled. The idea to use _Generic for type distinction is taken from Comment #7 in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108483 by Jakub Jelinek Signed-off-by: Michael Karcher Acked-by: Randy Dunlap # build-tested Link: https://lore.kernel.org/r/619fa552-c988-35e5-b1d7-fe256c46a272@mkarcher.dialup.fu-berlin.de Signed-off-by: John Paul Adrian Glaubitz Signed-off-by: Sasha Levin --- include/linux/sh_intc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/sh_intc.h b/include/linux/sh_intc.h index c255273b02810..37ad81058d6ae 100644 --- a/include/linux/sh_intc.h +++ b/include/linux/sh_intc.h @@ -97,7 +97,10 @@ struct intc_hw_desc { unsigned int nr_subgroups; }; -#define _INTC_ARRAY(a) a, __same_type(a, NULL) ? 0 : sizeof(a)/sizeof(*a) +#define _INTC_SIZEOF_OR_ZERO(a) (_Generic(a, \ + typeof(NULL): 0, \ + default: sizeof(a))) +#define _INTC_ARRAY(a) a, _INTC_SIZEOF_OR_ZERO(a)/sizeof(*a) #define INTC_HW_DESC(vectors, groups, mask_regs, \ prio_regs, sense_regs, ack_regs) \ -- 2.39.2