Skip to content

Commit 48f31e4

Browse files
AntonioBorneoMarc Zyngier
authored andcommitted
irqchip/stm32-exti: Fix warning on initialized field overwritten
While compiling with W=1, both gcc and clang complain about a tricky way to initialize an array by filling it with a non-zero value and then overrride some of the array elements. In this case the override is intentional, so just disable the specific warning for only this part of the code. Note: the flag "-Woverride-init" is recognized by both compilers, but the warning msg from clang reports "-Winitializer-overrides". The doc of clang clarifies that the two flags are synonyms, so use here only the flag name common on both compilers. Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com> Fixes: c297493 ("irqchip/stm32-exti: Simplify irq description table") Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230601155614.34490-1-antonio.borneo@foss.st.com
1 parent 1c51879 commit 48f31e4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/irqchip/irq-stm32-exti.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ static struct irq_chip stm32_exti_h_chip_direct;
173173
#define EXTI_INVALID_IRQ U8_MAX
174174
#define STM32MP1_DESC_IRQ_SIZE (ARRAY_SIZE(stm32mp1_exti_banks) * IRQS_PER_BANK)
175175

176+
/*
177+
* Use some intentionally tricky logic here to initialize the whole array to
178+
* EXTI_INVALID_IRQ, but then override certain fields, requiring us to indicate
179+
* that we "know" that there are overrides in this structure, and we'll need to
180+
* disable that warning from W=1 builds.
181+
*/
182+
__diag_push();
183+
__diag_ignore_all("-Woverride-init",
184+
"logic to initialize all and then override some is OK");
185+
176186
static const u8 stm32mp1_desc_irq[] = {
177187
/* default value */
178188
[0 ... (STM32MP1_DESC_IRQ_SIZE - 1)] = EXTI_INVALID_IRQ,
@@ -267,6 +277,8 @@ static const u8 stm32mp13_desc_irq[] = {
267277
[70] = 98,
268278
};
269279

280+
__diag_pop();
281+
270282
static const struct stm32_exti_drv_data stm32mp1_drv_data = {
271283
.exti_banks = stm32mp1_exti_banks,
272284
.bank_nr = ARRAY_SIZE(stm32mp1_exti_banks),

0 commit comments

Comments
 (0)