[rtems commit] coremsg.c: Clean up and comment improvement

Joel Sherrill joel at rtems.org
Fri Aug 31 14:55:12 UTC 2012


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

Author:    Joel Sherrill <joel.sherrill at oarcorp.com>
Date:      Fri Aug 31 09:58:42 2012 -0500

coremsg.c: Clean up and comment improvement

This code was reviewed as part of coverage analysis improvements.  The
uncovered range had unclear documentation and the code itself was also
cleaned up to be easier to understand.

Author: Krzysztof Mięsowicz <krzysztof.miesowicz at gmail.com>

---

 cpukit/score/src/coremsg.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c
index 72454b5..c55d2d5 100644
--- a/cpukit/score/src/coremsg.c
+++ b/cpukit/score/src/coremsg.c
@@ -82,16 +82,22 @@ bool _CORE_message_queue_Initialize(
   the_message_queue->maximum_message_size       = maximum_message_size;
   _CORE_message_queue_Set_notify( the_message_queue, NULL, NULL );
 
-  /*
-   *  Round size up to multiple of a pointer for chain init and
-   *  check for overflow on adding overhead to each message.
-   */
   allocated_message_size = maximum_message_size;
-  if (allocated_message_size & (sizeof(uint32_t) - 1)) {
-    allocated_message_size += sizeof(uint32_t);
-    allocated_message_size &= ~(sizeof(uint32_t) - 1);
+
+  /* 
+   * Check if allocated_message_size is aligned to uintptr-size boundary. 
+   * If not, it will increase allocated_message_size to multiplicity of pointer
+   * size.
+   */
+  if (allocated_message_size & (sizeof(uintptr_t) - 1)) {
+    allocated_message_size += sizeof(uintptr_t);
+    allocated_message_size &= ~(sizeof(uintptr_t) - 1);
   }
 
+  /* 
+   * Check for an overflow. It can occur while increasing allocated_message_size
+   * to multiplicity of uintptr_t above.
+   */
   if (allocated_message_size < maximum_message_size)
     return false;
 




More information about the vc mailing list