sched/semaphore: Fix setting EINVAL in sem_post() and sem_wait()

This commit is contained in:
Paul A. Patience 2016-06-28 10:06:30 -04:00
parent d4408264ec
commit 891113dac9
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;
}