Skip to content

Commit 13cde70

Browse files
ioannisggalak
authored andcommitted
tests: arm_no_multithreading: confirm IRQ index being non-negative
Check that the index returned by the function that looks for an available IRQ line is non-negative, and do not just rely on catching this with an ASSERT. That suppresses a Coverity out-of-bounds warning. Signed-off-by: Ioannis Glaropoulos <[email protected]>
1 parent 5c6df44 commit 13cde70

File tree

1 file changed

+15
-13
lines changed
  • tests/arch/arm/arm_no_multithreading/src

1 file changed

+15
-13
lines changed

tests/arch/arm/arm_no_multithreading/src/main.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,26 @@ void test_main(void)
9696
}
9797
}
9898

99-
__ASSERT(i >= 0,
100-
"No available IRQ line to use in the test\n");
99+
if (i >= 0) {
101100

102-
printk("Available IRQ line: %u\n", i);
101+
printk("Available IRQ line: %u\n", i);
103102

104-
arch_irq_connect_dynamic(i, 0 /* highest priority */,
105-
arm_isr_handler,
106-
NULL,
107-
0);
103+
arch_irq_connect_dynamic(i, 0 /* highest priority */,
104+
arm_isr_handler,
105+
NULL,
106+
0);
108107

109-
NVIC_EnableIRQ(i);
108+
NVIC_EnableIRQ(i);
110109

111-
__DSB();
112-
__ISB();
110+
__DSB();
111+
__ISB();
113112

114-
flag = test_flag;
113+
flag = test_flag;
115114

116-
__ASSERT(flag > 0, "Test flag not set by IRQ\n");
115+
__ASSERT(flag > 0, "Test flag not set by IRQ\n");
117116

118-
printk("ARM no multithreading test successful\n");
117+
printk("ARM no multithreading test successful\n");
118+
} else {
119+
__ASSERT(0, "No available IRQ line to use in the test\n");
120+
}
119121
}

0 commit comments

Comments
 (0)