You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2023/01/28 12:45:20 UTC
[nuttx] 02/02: sched/semaphore: correct the return value of sem_post()
This is an automated email from the ASF dual-hosted git repository.
masayuki pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 45e4bc5f3301042284bfdb9dd9ba3662d4ee70a1
Author: chao an <an...@xiaomi.com>
AuthorDate: Sat Jan 28 13:37:46 2023 +0800
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 <an...@xiaomi.com>
---
sched/semaphore/sem_post.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c
index 2a0d72987d..6c721d27b0 100644
--- a/sched/semaphore/sem_post.c
+++ b/sched/semaphore/sem_post.c
@@ -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.