This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e23f2546c3de26f03d73446121593e73aad89c6f Author: wangzhi16 <[email protected]> AuthorDate: Fri Aug 1 10:34:57 2025 +0800 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 <[email protected]> --- sched/semaphore/sem_trywait.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sched/semaphore/sem_trywait.c b/sched/semaphore/sem_trywait.c index 4f9ab9a4101..73ae795f9bb 100644 --- a/sched/semaphore/sem_trywait.c +++ b/sched/semaphore/sem_trywait.c @@ -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 {
