From 9d82150f5a83e8dcf985de26799f99f7c46ec515 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 26 Apr 2021 11:22:39 +0200 Subject: Return status code for _Scheduler_Set_affinity() This avoids having conditional statements to get the API-specific status code. --- cpukit/posix/src/pthreadcreate.c | 4 ++-- cpukit/posix/src/pthreadsetaffinitynp.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'cpukit/posix') diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index 75d3c64676..f53cd5e310 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -251,13 +251,13 @@ int pthread_create( the_thread->Life.state |= THREAD_LIFE_CHANGE_DEFERRED; _ISR_lock_ISR_disable( &lock_context ); - ok = _Scheduler_Set_affinity( + status = _Scheduler_Set_affinity( the_thread, the_attr->affinitysetsize, the_attr->affinityset ); _ISR_lock_ISR_enable( &lock_context ); - if ( !ok ) { + if ( status != STATUS_SUCCESSFUL ) { _Thread_Free( &_POSIX_Threads_Information, the_thread ); _RTEMS_Unlock_allocator(); return EINVAL; diff --git a/cpukit/posix/src/pthreadsetaffinitynp.c b/cpukit/posix/src/pthreadsetaffinitynp.c index ae91d135e1..9cb29ac167 100644 --- a/cpukit/posix/src/pthreadsetaffinitynp.c +++ b/cpukit/posix/src/pthreadsetaffinitynp.c @@ -28,6 +28,7 @@ #include #include +#include int pthread_setaffinity_np( pthread_t thread, @@ -38,7 +39,7 @@ int pthread_setaffinity_np( Thread_Control *the_thread; ISR_lock_Context lock_context; Per_CPU_Control *cpu_self; - bool ok; + Status_Control status; if ( cpuset == NULL ) { return EFAULT; @@ -53,7 +54,7 @@ int pthread_setaffinity_np( cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); _Thread_State_acquire_critical( the_thread, &lock_context ); - ok = _Scheduler_Set_affinity( + status = _Scheduler_Set_affinity( the_thread, cpusetsize, cpuset @@ -61,6 +62,6 @@ int pthread_setaffinity_np( _Thread_State_release( the_thread, &lock_context ); _Thread_Dispatch_enable( cpu_self ); - return ok ? 0 : EINVAL; + return _POSIX_Get_error( status ); } #endif -- cgit v1.2.3