[PATCH 25/27] score: Fix assertion in SMP scheduler framework

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Nov 15 17:12:57 UTC 2021


Properly assert that the scheduled chain is not empty.  Fix formatting.

Close #4531.
---
 cpukit/include/rtems/score/schedulersmpimpl.h | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/cpukit/include/rtems/score/schedulersmpimpl.h b/cpukit/include/rtems/score/schedulersmpimpl.h
index 6e2e21e544..97a77121ed 100644
--- a/cpukit/include/rtems/score/schedulersmpimpl.h
+++ b/cpukit/include/rtems/score/schedulersmpimpl.h
@@ -872,16 +872,19 @@ static inline Scheduler_Node *_Scheduler_SMP_Get_lowest_scheduled(
   Scheduler_Node    *filter
 )
 {
-  Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context );
-  Chain_Control *scheduled = &self->Scheduled;
-  Scheduler_Node *lowest_scheduled =
-    (Scheduler_Node *) _Chain_Last( scheduled );
+  Scheduler_SMP_Context *self;
+  Scheduler_Node        *lowest_scheduled;
 
   (void) filter;
 
-  _Assert( &lowest_scheduled->Node.Chain != _Chain_Tail( scheduled ) );
+  self = _Scheduler_SMP_Get_self( context );
+
+  _Assert( !_Chain_Is_empty( &self->Scheduled ) );
+  lowest_scheduled = (Scheduler_Node *) _Chain_Last( &self->Scheduled );
+
   _Assert(
-    _Chain_Next( &lowest_scheduled->Node.Chain ) == _Chain_Tail( scheduled )
+    _Chain_Next( &lowest_scheduled->Node.Chain ) ==
+      _Chain_Tail( &self->Scheduled )
   );
 
   return lowest_scheduled;
-- 
2.26.2



More information about the devel mailing list