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.laitinen@tii.ae>
This commit is contained in:
parent
9967593009
commit
84cb21791f
1 changed files with 2 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue