Merged in paulpatience/nuttx/semaphore (pull request #78)

sched/semaphore: Fix setting EINVAL in sem_post() and sem_wait()
This commit is contained in:
Gregory Nutt 2016-06-28 09:37:50 -06:00
commit 408c9d5c1c
2 changed files with 10 additions and 3 deletions

View File

@ -41,6 +41,7 @@
#include <limits.h>
#include <semaphore.h>
#include <errno.h>
#include <sched.h>
#include <nuttx/irq.h>
@ -157,6 +158,10 @@ int sem_post(FAR sem_t *sem)
leave_critical_section(flags);
}
else
{
set_errno(EINVAL);
}
return ret;
}

View File

@ -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;
}