pussuw commented on code in PR #16194: URL: https://github.com/apache/nuttx/pull/16194#discussion_r2058894333
########## 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: On the other hand, a mutex does not have a count, so reading an integer value for a mutex has no meaning. I suggest you remove this branch altogether or return some fixed value. I tried searching for a reference to nxmutex_get_value and there are none. -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org