summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/semsetpriority.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-03-23 16:36:09 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-11-15 11:14:12 +0100
commit1b5db7926b32a532906489620dfd39047d71cb49 (patch)
treea818e8d4d0ab9b44131ab2b619985412c58d8e7b /cpukit/rtems/src/semsetpriority.c
parentscore: Fix _CORE_ceiling_mutex_Set_priority() (diff)
downloadrtems-1b5db7926b32a532906489620dfd39047d71cb49.tar.bz2
rtems: Simplify rtems_semaphore_set_priority()
Do not write to the object referenced by old_priority in error paths. This is in line with other directives.
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/src/semsetpriority.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c
index 119dd85d77..97e53c6584 100644
--- a/cpukit/rtems/src/semsetpriority.c
+++ b/cpukit/rtems/src/semsetpriority.c
@@ -29,20 +29,6 @@
#include <rtems/rtems/tasksimpl.h>
#include <rtems/score/schedulerimpl.h>
-static rtems_status_code _Semaphore_Is_scheduler_valid(
- const CORE_ceiling_mutex_Control *the_mutex,
- const Scheduler_Control *scheduler
-)
-{
-#if defined(RTEMS_SMP)
- if ( scheduler != _CORE_ceiling_mutex_Get_scheduler( the_mutex ) ) {
- return RTEMS_NOT_DEFINED;
- }
-#endif
-
- return RTEMS_SUCCESSFUL;
-}
-
static rtems_status_code _Semaphore_Set_priority(
Semaphore_Control *the_semaphore,
const Scheduler_Control *scheduler,
@@ -51,7 +37,6 @@ static rtems_status_code _Semaphore_Set_priority(
Thread_queue_Context *queue_context
)
{
- rtems_status_code sc;
bool valid;
Priority_Control core_priority;
Priority_Control old_priority;
@@ -73,16 +58,26 @@ static rtems_status_code _Semaphore_Set_priority(
switch ( variant ) {
case SEMAPHORE_VARIANT_MUTEX_PRIORITY_CEILING:
- sc = _Semaphore_Is_scheduler_valid(
- &the_semaphore->Core_control.Mutex,
- scheduler
- );
+#if defined(RTEMS_SMP)
+ if (
+ scheduler != _CORE_ceiling_mutex_Get_scheduler(
+ &the_semaphore->Core_control.Mutex
+ )
+ ) {
+ _Thread_queue_Release(
+ &the_semaphore->Core_control.Wait_queue,
+ queue_context
+ );
+
+ return RTEMS_NOT_DEFINED;
+ }
+#endif
old_priority = _CORE_ceiling_mutex_Get_priority(
&the_semaphore->Core_control.Mutex
);
- if ( sc == RTEMS_SUCCESSFUL && new_priority != RTEMS_CURRENT_PRIORITY ) {
+ if ( new_priority != RTEMS_CURRENT_PRIORITY ) {
_CORE_ceiling_mutex_Set_priority(
&the_semaphore->Core_control.Mutex,
core_priority
@@ -105,7 +100,6 @@ static rtems_status_code _Semaphore_Set_priority(
);
}
- sc = RTEMS_SUCCESSFUL;
break;
#endif
default:
@@ -115,9 +109,12 @@ static rtems_status_code _Semaphore_Set_priority(
|| variant == SEMAPHORE_VARIANT_SIMPLE_BINARY
|| variant == SEMAPHORE_VARIANT_COUNTING
);
- old_priority = 0;
- sc = RTEMS_NOT_DEFINED;
- break;
+ _Thread_queue_Release(
+ &the_semaphore->Core_control.Wait_queue,
+ queue_context
+ );
+
+ return RTEMS_NOT_DEFINED;
}
cpu_self = _Thread_queue_Dispatch_disable( queue_context );
@@ -129,7 +126,7 @@ static rtems_status_code _Semaphore_Set_priority(
_Thread_Dispatch_enable( cpu_self );
*old_priority_p = _RTEMS_Priority_From_core( scheduler, old_priority );
- return sc;
+ return RTEMS_SUCCESSFUL;
}
rtems_status_code rtems_semaphore_set_priority(