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 <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2021-04-15 17:26:17 +02:00 committed by Kumar Gala
commit 13cde704e9

View file

@ -96,24 +96,26 @@ void test_main(void)
} }
} }
__ASSERT(i >= 0, if (i >= 0) {
"No available IRQ line to use in the test\n");
printk("Available IRQ line: %u\n", i); printk("Available IRQ line: %u\n", i);
arch_irq_connect_dynamic(i, 0 /* highest priority */, arch_irq_connect_dynamic(i, 0 /* highest priority */,
arm_isr_handler, arm_isr_handler,
NULL, NULL,
0); 0);
NVIC_EnableIRQ(i); NVIC_EnableIRQ(i);
__DSB(); __DSB();
__ISB(); __ISB();
flag = test_flag; flag = test_flag;
__ASSERT(flag > 0, "Test flag not set by IRQ\n"); __ASSERT(flag > 0, "Test flag not set by IRQ\n");
printk("ARM no multithreading test successful\n"); printk("ARM no multithreading test successful\n");
} else {
__ASSERT(0, "No available IRQ line to use in the test\n");
}
} }