[PATCH 2/2] rtems: Use _Objects_Free_nothing() for msg queues

Sebastian Huber sebastian.huber at embedded-brains.de
Mon May 10 17:41:25 UTC 2021


Use _Objects_Free_nothing() for rtems_message_queue_construct() to avoid
unreachable code in _CORE_message_queue_Close() in case only
user-provided message buffers are used.

Update #4007.
---
 cpukit/rtems/src/msgqconstruct.c | 7 ++++++-
 cpukit/score/src/coremsgclose.c  | 8 +++-----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/cpukit/rtems/src/msgqconstruct.c b/cpukit/rtems/src/msgqconstruct.c
index 6af57454cc..63ec75edff 100644
--- a/cpukit/rtems/src/msgqconstruct.c
+++ b/cpukit/rtems/src/msgqconstruct.c
@@ -41,7 +41,12 @@ static void *_Message_queue_Get_buffers(
     return NULL;
   }
 
-  the_message_queue->free_message_buffers = config->storage_free;
+  if ( config->storage_free != NULL ) {
+    the_message_queue->free_message_buffers = config->storage_free;
+  } else {
+    the_message_queue->free_message_buffers = _Objects_Free_nothing;
+  }
+
   return config->storage_area;
 }
 
diff --git a/cpukit/score/src/coremsgclose.c b/cpukit/score/src/coremsgclose.c
index 1610d8166b..aae3d5ae82 100644
--- a/cpukit/score/src/coremsgclose.c
+++ b/cpukit/score/src/coremsgclose.c
@@ -51,11 +51,9 @@ void _CORE_message_queue_Close(
     queue_context
   );
 
-  if ( the_message_queue->free_message_buffers != NULL ) {
-    ( *the_message_queue->free_message_buffers )(
-      the_message_queue->message_buffers
-    );
-  }
+  ( *the_message_queue->free_message_buffers )(
+    the_message_queue->message_buffers
+  );
 
   _Thread_queue_Destroy( &the_message_queue->Wait_queue );
 }
-- 
2.26.2



More information about the devel mailing list