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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 0f052df6dbe3c4b41e6e6b0a43babd0760e5d52e
Author: hujun5 <[email protected]>
AuthorDate: Thu Aug 14 19:22:56 2025 +0800

    sem_rw.c: coverity: HIS_metric_violation(HIS_GOTO)
    
    This change replaces goto-based control flow with structured if-else blocks
    in the up_read() function to comply with MISRA HIS coding standards while
    maintaining identical functional behavior.
    
    Signed-off-by: hujun5 <[email protected]>
---
 sched/semaphore/sem_rw.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sched/semaphore/sem_rw.c b/sched/semaphore/sem_rw.c
index 8b1c7e1d249..e7fe4d9d678 100644
--- a/sched/semaphore/sem_rw.c
+++ b/sched/semaphore/sem_rw.c
@@ -171,18 +171,17 @@ void up_read(FAR rw_semaphore_t *rwsem)
           rwsem->holder = RWSEM_NO_HOLDER;
           up_wait(rwsem);
         }
-
-      goto out;
     }
-
-  DEBUGASSERT(rwsem->reader > 0);
-
-  if (--rwsem->reader <= 0)
+  else
     {
-      up_wait(rwsem);
+      DEBUGASSERT(rwsem->reader > 0);
+
+      if (--rwsem->reader <= 0)
+        {
+          up_wait(rwsem);
+        }
     }
 
-out:
   nxmutex_unlock(&rwsem->protected);
 }
 

Reply via email to