From 02eaf3c9734a571b18cdbd5d454dc63eeb807011 Mon Sep 17 00:00:00 2001 From: pangzhen1 Date: Mon, 25 Aug 2025 22:19:41 +0800 Subject: [PATCH] sched/irq: Fix MISRA C-2012 Rule 10.4 - avoid implicit signed to unsigned cast This patch fixes a Coverity issue where implicit casting from signed int to unsigned int could lead to unexpected behavior. The fix replaces the implicit cast with an explicit unsigned literal suffix to ensure type safety. Changes: - In irqchain_attach(): Changed comparison 'sq_count(&g_irqchainfreelist) < 2' to 'sq_count(&g_irqchainfreelist) < 2u' to use explicit unsigned literal This ensures compliance with MISRA C-2012 Rule 10.4 which prohibits implicit conversions between signed and unsigned types. This change prevents potential integer conversion issues and improves code correctness. Signed-off-by: pangzhen1 --- sched/irq/irq_chain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sched/irq/irq_chain.c b/sched/irq/irq_chain.c index cb292ac45d2..fd9bd4ba8ad 100644 --- a/sched/irq/irq_chain.c +++ b/sched/irq/irq_chain.c @@ -154,7 +154,7 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg) { if (g_irqvector[ndx].handler != irqchain_dispatch) { - if (sq_count(&g_irqchainfreelist) < 2) + if (sq_count(&g_irqchainfreelist) < 2u) { spin_unlock_irqrestore(&g_irqchainlock, flags); return -ENOMEM;