This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 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 9131c0ec647 sched/addrenv: fix misra_c_2012_rule_15_5_violation
9131c0ec647 is described below

commit 9131c0ec6470538259172fd8c4c80c52c2255a71
Author: yukangzhi <[email protected]>
AuthorDate: Wed Oct 15 12:08:16 2025 +0800

    sched/addrenv: fix misra_c_2012_rule_15_5_violation
    
    In addrenv_join: The function should have only one exit point at its end.
    In addrenv_drop: The function should have only one exit point at its end.
    
    Signed-off-by: yukangzhi <[email protected]>
---
 sched/addrenv/addrenv.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/sched/addrenv/addrenv.c b/sched/addrenv/addrenv.c
index cfa3a95231c..28efa1241fb 100644
--- a/sched/addrenv/addrenv.c
+++ b/sched/addrenv/addrenv.c
@@ -443,19 +443,20 @@ int addrenv_join(FAR struct tcb_s *ptcb, FAR struct tcb_s 
*tcb)
   if (ret < 0)
     {
       berr("ERROR: up_addrenv_attach failed: %d\n", ret);
-      return ret;
     }
+  else
+    {
+      /* Take a reference to the address environment */
 
-  /* Take a reference to the address environment */
-
-  addrenv_take(ptcb->addrenv_own);
+      addrenv_take(ptcb->addrenv_own);
 
-  /* Share the parent's address environment */
+      /* Share the parent's address environment */
 
-  tcb->addrenv_own = ptcb->addrenv_own;
-  tcb->addrenv_curr = tcb->addrenv_own;
+      tcb->addrenv_own = ptcb->addrenv_own;
+      tcb->addrenv_curr = tcb->addrenv_own;
+    }
 
-  return OK;
+  return ret;
 }
 
 #ifdef CONFIG_ARCH_HAVE_FORK
@@ -683,16 +684,9 @@ int addrenv_give(FAR struct addrenv_s *addrenv)
 
 void addrenv_drop(FAR struct addrenv_s *addrenv, bool deferred)
 {
-  if (addrenv == NULL)
-    {
-      /* No address environment, get out */
-
-      return;
-    }
-
   /* If no more users, the address environment can be dropped */
 
-  if (addrenv_give(addrenv) == 0)
+  if (addrenv != NULL && addrenv_give(addrenv) == 0)
     {
       /* Defer dropping if requested to do so, otherwise drop at once */
 

Reply via email to