Skip to content

Commit

Permalink
Address reviewer feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll committed Apr 23, 2020
1 parent e94d679 commit 40d5457
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions rmw/src/message_sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ rmw_message_sequence_init(
RCUTILS_CHECK_ALLOCATOR(allocator, return RMW_RET_INVALID_ARGUMENT);

void * data = NULL;
if (size) {
if (size > 0u) {
data = allocator->allocate(sizeof(void *) * size, allocator->state);
if (!data) {
if (NULL == data) {
return RMW_RET_BAD_ALLOC;
}
}

sequence->data = data;
sequence->size = 0;
sequence->size = 0u;
sequence->capacity = size;
sequence->allocator = allocator;

Expand All @@ -58,8 +58,8 @@ rmw_message_sequence_fini(rmw_message_sequence_t * sequence)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(sequence, RMW_RET_INVALID_ARGUMENT);

if (sequence->data) {
assert(sequence->capacity > 0);
if (NULL != sequence->data) {
assert(sequence->capacity > 0u);
RCUTILS_CHECK_ALLOCATOR(sequence->allocator, return RMW_RET_INVALID_ARGUMENT);
sequence->allocator->deallocate(sequence->data, sequence->allocator->state);
}
Expand Down Expand Up @@ -95,9 +95,9 @@ rmw_message_info_sequence_init(
RCUTILS_CHECK_ALLOCATOR(allocator, return RMW_RET_INVALID_ARGUMENT);

rmw_message_info_t * data = NULL;
if (size) {
if (size > 0u) {
data = allocator->allocate(sizeof(rmw_message_info_t) * size, allocator->state);
if (!data) {
if (NULL == data) {
return RMW_RET_BAD_ALLOC;
}
}
Expand All @@ -114,8 +114,8 @@ rmw_message_info_sequence_fini(rmw_message_info_sequence_t * sequence)
{
RCUTILS_CHECK_ARGUMENT_FOR_NULL(sequence, RMW_RET_INVALID_ARGUMENT);

if (sequence->data) {
assert(sequence->capacity > 0);
if (NULL != sequence->data) {
assert(sequence->capacity > 0u);
RCUTILS_CHECK_ALLOCATOR(sequence->allocator, return RMW_RET_INVALID_ARGUMENT);
sequence->allocator->deallocate(sequence->data, sequence->allocator->state);
}
Expand Down

0 comments on commit 40d5457

Please sign in to comment.