diff options
author | Joel Sherrill <joel.sherrill@oarcorp.com> | 2012-08-31 09:58:42 -0500 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@oarcorp.com> | 2012-08-31 09:58:42 -0500 |
commit | d658a9bfc33e4f773444f2f74a7d4ff95716387d (patch) | |
tree | ba4d0ea7cf7670cec2eefeff70cf4134bbbf2a64 /cpukit | |
parent | timespec: Add documentation for struct timespec Helpers (diff) | |
download | rtems-d658a9bfc33e4f773444f2f74a7d4ff95716387d.tar.bz2 |
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@gmail.com>
Diffstat (limited to 'cpukit')
-rw-r--r-- | 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 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; |