mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 13:52:22 +08:00
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 <hujun5@xiaomi.com>
This commit is contained in:
+15
-15
@@ -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.
|
||||
*/
|
||||
|
||||
rwsem->reader++;
|
||||
}
|
||||
|
||||
/* In a scenario where there is no write lock, we just need to make the
|
||||
* read base +1.
|
||||
*/
|
||||
|
||||
rwsem->reader++;
|
||||
|
||||
out:
|
||||
nxmutex_unlock(&rwsem->protected);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user