This is an automated email from the ASF dual-hosted git repository. lupyuen 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 84cb21791f libc/semaphore: Read semaphore value by using NXSEM_COUNT macro 84cb21791f is described below commit 84cb21791face87ba8633b03582e9f4d4bc9bb18 Author: Jukka Laitinen <jukka.laiti...@tii.ae> AuthorDate: Thu Apr 3 11:30:52 2025 +0300 libc/semaphore: Read semaphore value by using NXSEM_COUNT macro We should not access semaphore internals directly outside sched/semaphore. Just read it via the NXSEM_COUNT macro provided. Signed-off-by: Jukka Laitinen <jukka.laiti...@tii.ae> --- libs/libc/semaphore/sem_getvalue.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/libc/semaphore/sem_getvalue.c b/libs/libc/semaphore/sem_getvalue.c index 194f5fa1ef..14706cea05 100644 --- a/libs/libc/semaphore/sem_getvalue.c +++ b/libs/libc/semaphore/sem_getvalue.c @@ -29,6 +29,7 @@ #include <errno.h> #include <nuttx/semaphore.h> +#include <nuttx/atomic.h> /**************************************************************************** * Public Functions @@ -64,7 +65,7 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval) { if (sem != NULL && sval != NULL) { - *sval = sem->semcount; + *sval = atomic_read(NXSEM_COUNT(sem)); return OK; }