libc/pthread: Return EINVAL when input parameter incorrect at pthread_once
https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_once.html If an implementation detects that the value specified by the once_control argument to pthread_once() does not refer to a pthread_once_t object initialized by PTHREAD_ONCE_INIT, it is recommended that the function should fail and report an [EINVAL] error. Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
This commit is contained in:
parent
ff6ba02378
commit
962dfaf651
1 changed files with 5 additions and 2 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdbool.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
|
|
@ -65,8 +66,10 @@ int pthread_once(FAR pthread_once_t *once_control,
|
|||
{
|
||||
/* Sanity checks */
|
||||
|
||||
DEBUGASSERT(once_control != NULL);
|
||||
DEBUGASSERT(init_routine != NULL);
|
||||
if (once_control == NULL || init_routine == NULL)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* Prohibit pre-emption while we test and set the once_control. */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue