diff --git a/sched/irq/irq_attach.c b/sched/irq/irq_attach.c index a992c927931..690d059ad99 100644 --- a/sched/irq/irq_attach.c +++ b/sched/irq/irq_attach.c @@ -111,7 +111,7 @@ int irq_attach(int irq, xcpt_t isr, FAR void *arg) #if NR_IRQS > 0 int ret = -EINVAL; - if ((unsigned)irq < NR_IRQS) + if (irq >= 0 && irq < NR_IRQS) { int ndx = IRQ_TO_NDX(irq); irqstate_t flags; diff --git a/sched/irq/irq_attach_thread.c b/sched/irq/irq_attach_thread.c index ef5f98e599c..02d47b58505 100644 --- a/sched/irq/irq_attach_thread.c +++ b/sched/irq/irq_attach_thread.c @@ -99,7 +99,7 @@ static int isr_thread_main(int argc, FAR char *argv[]) info.arg = arg; info.handler = isr; - nxsem_init(&sem, 0, 0); + nxsem_init(&sem, 0, 0u); irq_attach(irq, irq_thread_default_handler, &info); @@ -159,7 +159,7 @@ int irq_attach_thread(int irq, xcpt_t isr, xcpt_t isrthread, FAR void *arg, pid_t pid; int ndx; - if ((unsigned)irq >= NR_IRQS) + if (irq < 0 || irq >= NR_IRQS) { return -EINVAL; } diff --git a/sched/irq/irq_attach_wqueue.c b/sched/irq/irq_attach_wqueue.c index fc1eb11539d..7f7b33ed9b4 100644 --- a/sched/irq/irq_attach_wqueue.c +++ b/sched/irq/irq_attach_wqueue.c @@ -138,7 +138,7 @@ static int irq_default_handler(int irq, FAR void *regs, FAR void *arg) if (ret == IRQ_WAKE_THREAD) { - work_queue_wq(info->wqueue, &info->work, irq_work_handler, info, 0); + work_queue_wq(info->wqueue, &info->work, irq_work_handler, info, 0u); ret = OK; } @@ -179,7 +179,7 @@ int irq_attach_wqueue(int irq, xcpt_t isr, xcpt_t isrwork, #if NR_IRQS > 0 int ndx; - if ((unsigned)irq >= NR_IRQS) + if (irq < 0 || irq >= NR_IRQS) { return -EINVAL; } diff --git a/sched/irq/irq_dispatch.c b/sched/irq/irq_dispatch.c index 71dc5a14762..0b8cde958d6 100644 --- a/sched/irq/irq_dispatch.c +++ b/sched/irq/irq_dispatch.c @@ -102,10 +102,10 @@ void irq_dispatch(int irq, FAR void *context) #endif xcpt_t vector = irq_unexpected_isr; FAR void *arg = NULL; - unsigned int ndx = irq; + int ndx = irq; #if NR_IRQS > 0 - if ((unsigned)irq < NR_IRQS) + if (irq >= 0 && irq < NR_IRQS) { #ifdef CONFIG_ARCH_MINIMAL_VECTORTABLE ndx = g_irqmap[irq];