mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
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:
@@ -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. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user