From 14526992418137af1b64d8be02a30fd91406195a Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 26 Apr 2021 10:34:11 +0200 Subject: Return status code for _Scheduler_Get_affinity() This avoids having conditional statements to get the API-specific status code. --- cpukit/posix/src/pthreadgetaffinitynp.c | 7 ++++--- cpukit/posix/src/pthreadgetattrnp.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'cpukit/posix/src') diff --git a/cpukit/posix/src/pthreadgetaffinitynp.c b/cpukit/posix/src/pthreadgetaffinitynp.c index 977f82c69b..b904aea36c 100644 --- a/cpukit/posix/src/pthreadgetaffinitynp.c +++ b/cpukit/posix/src/pthreadgetaffinitynp.c @@ -28,6 +28,7 @@ #include #include +#include int pthread_getaffinity_np( pthread_t thread, @@ -38,7 +39,7 @@ int pthread_getaffinity_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_getaffinity_np( cpu_self = _Thread_Dispatch_disable_critical( &lock_context ); _Thread_State_acquire_critical( the_thread, &lock_context ); - ok = _Scheduler_Get_affinity( + status = _Scheduler_Get_affinity( the_thread, cpusetsize, cpuset @@ -61,7 +62,7 @@ int pthread_getaffinity_np( _Thread_State_release( the_thread, &lock_context ); _Thread_Dispatch_enable( cpu_self ); - return ok ? 0 : EINVAL; + return _POSIX_Get_error( status ); } #endif diff --git a/cpukit/posix/src/pthreadgetattrnp.c b/cpukit/posix/src/pthreadgetattrnp.c index eae29d1de7..5572fb98a5 100644 --- a/cpukit/posix/src/pthreadgetattrnp.c +++ b/cpukit/posix/src/pthreadgetattrnp.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,7 @@ int pthread_getattr_np( Thread_CPU_budget_algorithms budget_algorithm; const Scheduler_Control *scheduler; Priority_Control priority; - bool ok; + Status_Control status; if ( attr == NULL ) { return EINVAL; @@ -82,7 +83,7 @@ int pthread_getattr_np( attr->affinityset = &attr->affinitysetpreallocated; attr->affinitysetsize = sizeof( attr->affinitysetpreallocated ); - ok = _Scheduler_Get_affinity( + status = _Scheduler_Get_affinity( the_thread, attr->affinitysetsize, attr->affinityset @@ -102,5 +103,5 @@ int pthread_getattr_np( attr->schedpolicy = _POSIX_Thread_Translate_to_sched_policy( budget_algorithm ); - return ok ? 0 : EINVAL; + return _POSIX_Get_error( status ); } -- cgit v1.2.3