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

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

commit 437cdfac8de70c6487b2f76f514dfcd4a2da54ab
Author: hujun5 <[email protected]>
AuthorDate: Thu Aug 14 19:25:21 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 down_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 | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sched/semaphore/sem_rw.c b/sched/semaphore/sem_rw.c
index 105710a1bb5..7aa8e05be74 100644
--- a/sched/semaphore/sem_rw.c
+++ b/sched/semaphore/sem_rw.c
@@ -123,25 +123,25 @@ void down_read(FAR rw_semaphore_t *rwsem)
   if (rwsem->holder == _SCHED_GETTID())
     {
       rwsem->writer++;
-      goto out;
     }
-
-  while (rwsem->writer > 0)
+  else
     {
-      rwsem->waiter++;
-      nxmutex_unlock(&rwsem->protected);
-      nxsem_wait(&rwsem->waiting);
-      nxmutex_lock(&rwsem->protected);
-      rwsem->waiter--;
-    }
+      while (rwsem->writer > 0)
+        {
+          rwsem->waiter++;
+          nxmutex_unlock(&rwsem->protected);
+          nxsem_wait(&rwsem->waiting);
+          nxmutex_lock(&rwsem->protected);
+          rwsem->waiter--;
+        }
 
-  /* In a scenario where there is no write lock, we just need to make the
-   * read base +1.
-   */
+      /* In a scenario where there is no write lock, we just need to make the
+       * read base +1.
+       */
 
-  rwsem->reader++;
+      rwsem->reader++;
+    }
 
-out:
   nxmutex_unlock(&rwsem->protected);
 }
 

Reply via email to