diff --git a/sched/semaphore/sem_post.c b/sched/semaphore/sem_post.c index 97235de428..c985ceb9c4 100644 --- a/sched/semaphore/sem_post.c +++ b/sched/semaphore/sem_post.c @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -157,6 +158,10 @@ int sem_post(FAR sem_t *sem) leave_critical_section(flags); } + else + { + set_errno(EINVAL); + } return ret; } diff --git a/sched/semaphore/sem_wait.c b/sched/semaphore/sem_wait.c index 86fb013696..49371e0ae6 100644 --- a/sched/semaphore/sem_wait.c +++ b/sched/semaphore/sem_wait.c @@ -86,9 +86,7 @@ int sem_wait(FAR sem_t *sem) DEBUGASSERT(up_interrupt_context() == false); - /* Assume any errors reported are due to invalid arguments. */ - - set_errno(EINVAL); + /* Make sure we were supplied with a valid semaphore. */ if (sem) { @@ -190,6 +188,10 @@ int sem_wait(FAR sem_t *sem) leave_critical_section(flags); } + else + { + set_errno(EINVAL); + } return ret; }