nuttx/sched/irq
pangzhen1 7b154402fb sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro
Previously, IRQ bounds checking (irq >= 0 && irq < NR_IRQS) was duplicated
across multiple IRQ subsystem functions before calling IRQ_TO_NDX(). This
led to code duplication and inconsistency.

This patch consolidates all IRQ bounds checking into the IRQ_TO_NDX() macro
itself, which now returns -EINVAL for out-of-bounds IRQ numbers. This approach:

1. Eliminates duplicated bounds checking code
2. Ensures consistent error handling across all IRQ functions
3. Simplifies caller code - just check if IRQ_TO_NDX() returns negative
4. Makes the macro behavior more predictable and self-contained

Changes:
- Modified IRQ_TO_NDX() to check (irq < 0 || irq >= NR_IRQS) and return -EINVAL
- Removed redundant IRQ range checks in irq_attach(), irq_attach_thread(),
  irq_attach_wqueue(), and irqchain_detach()
- Simplified error handling to check ndx < 0 after IRQ_TO_NDX() call

This consolidation reduces code size and improves maintainability while
preserving all existing error checking functionality.

Signed-off-by: pangzhen1 <pangzhen1@xiaomi.com>
2026-01-28 13:35:30 +08:00
..
CMakeLists.txt isrthread: add configuring the stack of an isrthread as static 2024-11-08 01:49:14 +08:00
irq.h arch/tricore: support minimal vectortalbe in tricore 2026-01-19 17:51:48 +08:00
irq_attach.c sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
irq_attach_thread.c sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
irq_attach_wqueue.c sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
irq_chain.c sched/irq: Consolidate IRQ bounds checking into IRQ_TO_NDX macro 2026-01-28 13:35:30 +08:00
irq_csection.c sched/spinlock: Update the information of critmon in docu. 2026-01-27 21:59:14 +08:00
irq_dispatch.c sched/irq: Fix type mismatch in irq_dispatch (MISRA C-2012 Rule 10.3) 2026-01-27 22:28:23 +08:00
irq_foreach.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
irq_initialize.c debug/0 address: Add 0 address access panic configuration 2025-06-26 19:25:31 +08:00
irq_procfs.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
irq_spinlock.c sched: remove spin_lock_irqsave(NULL) support 2025-01-10 22:35:14 +08:00
irq_unexpectedisr.c sched: migrate to SPDX identifier 2024-09-12 01:10:14 +08:00
Make.defs isrthread: add configuring the stack of an isrthread as static 2024-11-08 01:49:14 +08:00