mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +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:
@@ -123,9 +123,9 @@ void down_read(FAR rw_semaphore_t *rwsem)
|
|||||||
if (rwsem->holder == _SCHED_GETTID())
|
if (rwsem->holder == _SCHED_GETTID())
|
||||||
{
|
{
|
||||||
rwsem->writer++;
|
rwsem->writer++;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
while (rwsem->writer > 0)
|
while (rwsem->writer > 0)
|
||||||
{
|
{
|
||||||
rwsem->waiter++;
|
rwsem->waiter++;
|
||||||
@@ -140,8 +140,8 @@ void down_read(FAR rw_semaphore_t *rwsem)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
rwsem->reader++;
|
rwsem->reader++;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
|
||||||
nxmutex_unlock(&rwsem->protected);
|
nxmutex_unlock(&rwsem->protected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user