This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 300992203a libs/libc/semaphore: Fix DEBUGASSERTS
300992203a is described below
commit 300992203ac0a14602c8cf744ec87d5525fe4dfb
Author: Jukka Laitinen <[email protected]>
AuthorDate: Wed Apr 9 12:59:21 2025 +0300
libs/libc/semaphore: Fix DEBUGASSERTS
The DEBUGASSERTS in nxsem_wait and nxsem_trywait were non-functional, they
didn't check anything.
Signed-off-by: Jukka Laitinen <[email protected]>
---
libs/libc/semaphore/sem_trywait.c | 7 +++----
libs/libc/semaphore/sem_wait.c | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/libs/libc/semaphore/sem_trywait.c
b/libs/libc/semaphore/sem_trywait.c
index 4cd4b1c59c..87e3fb8d55 100644
--- a/libs/libc/semaphore/sem_trywait.c
+++ b/libs/libc/semaphore/sem_trywait.c
@@ -106,13 +106,12 @@ int sem_trywait(FAR sem_t *sem)
int nxsem_trywait(FAR sem_t *sem)
{
- DEBUGASSERT(sem != NULL);
-
/* This API should not be called from the idleloop or interrupt */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
- DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
- up_interrupt_context());
+ DEBUGASSERT(sem != NULL);
+ DEBUGASSERT(!up_interrupt_context());
+ DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
#endif
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that
diff --git a/libs/libc/semaphore/sem_wait.c b/libs/libc/semaphore/sem_wait.c
index 77e03377d6..0c56db9d96 100644
--- a/libs/libc/semaphore/sem_wait.c
+++ b/libs/libc/semaphore/sem_wait.c
@@ -134,13 +134,12 @@ errout_with_cancelpt:
int nxsem_wait(FAR sem_t *sem)
{
- DEBUGASSERT(sem != NULL);
-
/* This API should not be called from the idleloop or interrupt */
#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
- DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask() ||
- up_interrupt_context());
+ DEBUGASSERT(sem != NULL);
+ DEBUGASSERT(!up_interrupt_context());
+ DEBUGASSERT(!OSINIT_IDLELOOP() || !sched_idletask());
#endif
/* We don't do atomic fast path in case of LIBC_ARCH_ATOMIC because that