You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/01/22 14:15:37 UTC
(nuttx) 01/02: sched/irq: Fix MISRA C-2012 Rule 10.4 - avoid implicit signed to unsigned cast
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 02eaf3c9734a571b18cdbd5d454dc63eeb807011
Author: pangzhen1 <pa...@xiaomi.com>
AuthorDate: Mon Aug 25 22:19:41 2025 +0800
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 <pa...@xiaomi.com>
---
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;