stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>,
	Randy Dunlap <rdunlap@infradead.org>,
	John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.15 09/10] sh: intc: Avoid spurious sizeof-pointer-div warning
Date: Tue, 14 Mar 2023 08:43:43 -0400	[thread overview]
Message-ID: <20230314124344.471127-9-sashal@kernel.org> (raw)
In-Reply-To: <20230314124344.471127-1-sashal@kernel.org>

From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>

[ 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 <kernel@mkarcher.dialup.fu-berlin.de>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # 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 <glaubitz@physik.fu-berlin.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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


  parent reply	other threads:[~2023-03-14 12:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 12:43 [PATCH AUTOSEL 5.15 01/10] mmc: atmel-mci: fix race between stop command and start of next command Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 02/10] jffs2: correct logic when creating a hole in jffs2_write_begin Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 03/10] rust: arch/um: Disable FP/SIMD instruction to match x86 Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 04/10] ext4: fail ext4_iget if special inode unallocated Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 05/10] ext4: update s_journal_inum if it changes after journal replay Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 06/10] ext4: fix task hung in ext4_xattr_delete_inode Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 07/10] drm/amdkfd: Fix an illegal memory access Sasha Levin
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 08/10] net/9p: fix bug in client create for .L Sasha Levin
2023-03-14 12:43 ` Sasha Levin [this message]
2023-03-14 12:43 ` [PATCH AUTOSEL 5.15 10/10] drm/amd/display: fix shift-out-of-bounds in CalculateVMAndRowBytes Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230314124344.471127-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=kernel@mkarcher.dialup.fu-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).