sched/sem : Optimize code

Simplify sem_trywait() code structure by removing redundant logic and
consolidating return paths. This optimization maintains functional correctness
while improving code clarity and reducing cyclomatic complexity.

Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
This commit is contained in:
wangzhi16
2025-08-01 10:34:57 +08:00
committed by Alan C. Assis
parent 7443a13bf9
commit e23f2546c3
+2 -5
View File
@@ -77,11 +77,6 @@ int nxsem_trywait_slow(FAR sem_t *sem)
/* If the semaphore is available, give it to the requesting task */
if (mutex)
{
new = nxsched_gettid();
}
old = atomic_read(val);
do
{
@@ -91,6 +86,8 @@ int nxsem_trywait_slow(FAR sem_t *sem)
{
goto out;
}
new = nxsched_gettid();
}
else
{