This is an automated email from the ASF dual-hosted git repository.
ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 5a1a7dc38e8 sched/irq: Every function must have exactly one entry
point and one exit point
5a1a7dc38e8 is described below
commit 5a1a7dc38e87b69f385356612b591b86c6178166
Author: pangzhen1 <[email protected]>
AuthorDate: Mon Aug 25 21:59:10 2025 +0800
sched/irq: Every function must have exactly one entry point and one exit
point
According to MISRA C-2004 Rule 14.7, Every function must have exactly one
entry point and one exit point.
Signed-off-by: pangzhen1 <[email protected]>
---
sched/irq/irq_chain.c | 69 +++++++++++++++++++++++++++++----------------------
1 file changed, 39 insertions(+), 30 deletions(-)
diff --git a/sched/irq/irq_chain.c b/sched/irq/irq_chain.c
index 757ca963d8e..a7ef808ac8a 100644
--- a/sched/irq/irq_chain.c
+++ b/sched/irq/irq_chain.c
@@ -128,19 +128,23 @@ void irqchain_initialize(void)
bool is_irqchain(int ndx, xcpt_t isr)
{
+ bool ret;
+
if (g_irqvector[ndx].handler == irq_unexpected_isr ||
g_irqvector[ndx].handler == NULL)
{
- return false;
+ ret = false;
}
else if (g_irqvector[ndx].handler == irqchain_dispatch)
{
- return true;
+ ret = true;
}
else
{
- return isr != irq_unexpected_isr;
+ ret = isr != irq_unexpected_isr;
}
+
+ return ret;
}
int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
@@ -148,6 +152,7 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
FAR struct irqchain_s *node;
FAR struct irqchain_s *curr;
irqstate_t flags;
+ int ret = 0;
flags = spin_lock_irqsave(&g_irqchainlock);
if (isr != irq_unexpected_isr)
@@ -156,39 +161,43 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
{
if (sq_count(&g_irqchainfreelist) < 2u)
{
- spin_unlock_irqrestore(&g_irqchainlock, flags);
- return -ENOMEM;
+ ret = -ENOMEM;
}
+ else
+ {
+ node = (FAR struct irqchain_s *)
+ sq_remfirst(&g_irqchainfreelist);
+ DEBUGASSERT(node != NULL);
- node = (FAR struct irqchain_s *)sq_remfirst(&g_irqchainfreelist);
- DEBUGASSERT(node != NULL);
+ node->handler = g_irqvector[ndx].handler;
+ node->arg = g_irqvector[ndx].arg;
+ node->next = NULL;
- node->handler = g_irqvector[ndx].handler;
- node->arg = g_irqvector[ndx].arg;
- node->next = NULL;
+ g_irqvector[ndx].handler = irqchain_dispatch;
+ g_irqvector[ndx].arg = node;
- g_irqvector[ndx].handler = irqchain_dispatch;
- g_irqvector[ndx].arg = node;
- }
-
- node = (FAR struct irqchain_s *)sq_remfirst(&g_irqchainfreelist);
- if (node == NULL)
- {
- spin_unlock_irqrestore(&g_irqchainlock, flags);
- return -ENOMEM;
- }
+ node = (FAR struct irqchain_s *)
+ sq_remfirst(&g_irqchainfreelist);
+ if (node == NULL)
+ {
+ ret = -ENOMEM;
+ }
+ else
+ {
+ node->handler = isr;
+ node->arg = arg;
+ node->next = NULL;
- node->handler = isr;
- node->arg = arg;
- node->next = NULL;
+ curr = g_irqvector[ndx].arg;
+ while (curr->next != NULL)
+ {
+ curr = curr->next;
+ }
- curr = g_irqvector[ndx].arg;
- while (curr->next != NULL)
- {
- curr = curr->next;
+ curr->next = node;
+ }
+ }
}
-
- curr->next = node;
}
else
{
@@ -196,7 +205,7 @@ int irqchain_attach(int ndx, xcpt_t isr, FAR void *arg)
}
spin_unlock_irqrestore(&g_irqchainlock, flags);
- return OK;
+ return ret;
}
int irqchain_detach(int irq, xcpt_t isr, FAR void *arg)