From d658a9bfc33e4f773444f2f74a7d4ff95716387d Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 31 Aug 2012 09:58:42 -0500 Subject: coremsg.c: Clean up and comment improvement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- cpukit/score/src/coremsg.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'cpukit/score/src/coremsg.c') diff --git a/cpukit/score/src/coremsg.c b/cpukit/score/src/coremsg.c index 72454b5d44..c55d2d5a82 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; -- cgit v1.2.3