[rtems commit] score: Fix assertion in SMP scheduler framework

Sebastian Huber sebh at rtems.org
Tue Nov 23 13:34:54 UTC 2021


Module:    rtems
Branch:    master
Commit:    6443c9dbb7dda8a19ae311c126a19d16ec975ae8
Changeset: http://git.rtems.org/rtems/commit/?id=6443c9dbb7dda8a19ae311c126a19d16ec975ae8

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov 10 08:54:03 2021 +0100

score: Fix assertion in SMP scheduler framework

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 6e2e21e..97a7712 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;



More information about the vc mailing list