sched/semaphore: correct the return value of sem_post()

sem_post() should return EOVERFLOW if maximum allowable value for
a semaphore would be exceeded.

Reference:
https://man7.org/linux/man-pages/man3/sem_post.3.html

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-01-28 13:37:46 +08:00
committed by Masayuki Ishikawa
parent b9d70365a1
commit 45e4bc5f33
+5 -1
View File
@@ -89,7 +89,11 @@ int nxsem_post(FAR sem_t *sem)
/* Check the maximum allowable value */
DEBUGASSERT(sem_count < SEM_VALUE_MAX);
if (sem_count >= SEM_VALUE_MAX)
{
leave_critical_section(flags);
return -EOVERFLOW;
}
/* Perform the semaphore unlock operation, releasing this task as a
* holder then also incrementing the count on the semaphore.