[rtems commit] score: Gather message queue control initialization

Sebastian Huber sebh at rtems.org
Mon Sep 28 05:17:52 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Sep 21 08:15:27 2020 +0200

score: Gather message queue control initialization

Initialize the structure in a single code block after the error checks and
calculations.

Update #4007.

---

 cpukit/score/src/coremsg.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index 04c1799..0246a3a 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -35,11 +35,6 @@ bool _CORE_message_queue_Initialize(
 {
   size_t buffer_size;
 
-  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
-  the_message_queue->number_of_pending_messages = 0;
-  the_message_queue->maximum_message_size       = maximum_message_size;
-  _CORE_message_queue_Set_notify( the_message_queue, NULL );
-
   /* Make sure the message size computation does not overflow */
   if ( maximum_message_size > MESSAGE_SIZE_LIMIT ) {
     return false;
@@ -64,19 +59,12 @@ bool _CORE_message_queue_Initialize(
     return false;
   }
 
-  /*
-   *  Initialize the pool of inactive messages, pending messages,
-   *  and set of waiting threads.
-   */
-  _Chain_Initialize (
-    &the_message_queue->Inactive_messages,
-    the_message_queue->message_buffers,
-    (size_t) maximum_pending_messages,
-    buffer_size
-  );
+  the_message_queue->maximum_pending_messages   = maximum_pending_messages;
+  the_message_queue->number_of_pending_messages = 0;
+  the_message_queue->maximum_message_size       = maximum_message_size;
 
+  _CORE_message_queue_Set_notify( the_message_queue, NULL );
   _Chain_Initialize_empty( &the_message_queue->Pending_messages );
-
   _Thread_queue_Object_initialize( &the_message_queue->Wait_queue );
 
   if ( discipline == CORE_MESSAGE_QUEUE_DISCIPLINES_PRIORITY ) {
@@ -85,5 +73,12 @@ bool _CORE_message_queue_Initialize(
     the_message_queue->operations = &_Thread_queue_Operations_FIFO;
   }
 
+  _Chain_Initialize (
+    &the_message_queue->Inactive_messages,
+    the_message_queue->message_buffers,
+    (size_t) maximum_pending_messages,
+    buffer_size
+  );
+
   return true;
 }



More information about the vc mailing list