From 8c56e43c13c42e061b746d9e012b3740e697865a Mon Sep 17 00:00:00 2001 From: Ioannis Glaropoulos Date: Thu, 15 Apr 2021 17:26:17 +0200 Subject: [PATCH] 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 --- .../arch/arm/arm_no_multithreading/src/main.c | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/arch/arm/arm_no_multithreading/src/main.c b/tests/arch/arm/arm_no_multithreading/src/main.c index 1688b4c5740c97..e9bfbace06736b 100644 --- a/tests/arch/arm/arm_no_multithreading/src/main.c +++ b/tests/arch/arm/arm_no_multithreading/src/main.c @@ -96,24 +96,26 @@ void test_main(void) } } - __ASSERT(i >= 0, - "No available IRQ line to use in the test\n"); + if (i >= 0) { - printk("Available IRQ line: %u\n", i); + printk("Available IRQ line: %u\n", i); - arch_irq_connect_dynamic(i, 0 /* highest priority */, - arm_isr_handler, - NULL, - 0); + arch_irq_connect_dynamic(i, 0 /* highest priority */, + arm_isr_handler, + NULL, + 0); - NVIC_EnableIRQ(i); + NVIC_EnableIRQ(i); - __DSB(); - __ISB(); + __DSB(); + __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"); + } }