mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:22:32 +08:00
sched/semaphore: Fix setting EINVAL in sem_post() and sem_wait()
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <semaphore.h>
|
#include <semaphore.h>
|
||||||
|
#include <errno.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
@@ -157,6 +158,10 @@ int sem_post(FAR sem_t *sem)
|
|||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_errno(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,9 +86,7 @@ int sem_wait(FAR sem_t *sem)
|
|||||||
|
|
||||||
DEBUGASSERT(up_interrupt_context() == false);
|
DEBUGASSERT(up_interrupt_context() == false);
|
||||||
|
|
||||||
/* Assume any errors reported are due to invalid arguments. */
|
/* Make sure we were supplied with a valid semaphore. */
|
||||||
|
|
||||||
set_errno(EINVAL);
|
|
||||||
|
|
||||||
if (sem)
|
if (sem)
|
||||||
{
|
{
|
||||||
@@ -190,6 +188,10 @@ int sem_wait(FAR sem_t *sem)
|
|||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
set_errno(EINVAL);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user