jlaitine commented on code in PR #16194:
URL: https://github.com/apache/nuttx/pull/16194#discussion_r2058998349
##########
libs/libc/semaphore/sem_getvalue.c:
##########
@@ -65,7 +69,23 @@ int nxsem_get_value(FAR sem_t *sem, FAR int *sval)
{
if (sem != NULL && sval != NULL)
{
- *sval = atomic_read(NXSEM_COUNT(sem));
+ if (NXSEM_IS_MUTEX(sem))
+ {
+ uint32_t mholder = atomic_read(NXSEM_MHOLDER(sem));
+ if (NXSEM_MACQUIRED(mholder))
+ {
+ *sval = NXSEM_MBLOCKS(mholder) ? -1 : 0;
Review Comment:
Yes I agree. This is a leftovers from nxmutex being based on counting
semaphore, I'll remove that. nxsem_getvalue for a mutex should just return
-EINVAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]