mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
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 <pangzhen1@xiaomi.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user