mirror of
https://github.com/apache/nuttx.git
synced 2026-08-18 20:18:17 +00:00
sched/semaphore: Fix setting EINVAL in sem_post() and sem_wait()
This commit is contained in:
parent
d4408264ec
commit
891113dac9
2 changed files with 10 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue