Skip to content

Commit

Permalink
Workaround 'condition my_chunk_ptr is always false' cppcheck false po…
Browse files Browse the repository at this point in the history
…sitive

* src/atomic_ops_malloc.c (get_chunk): Move get_mmaped() call into the
for loop; replace return statement inside the loop with break.
  • Loading branch information
ivmai committed Oct 19, 2018
1 parent cbde60d commit 71d1c4d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/atomic_ops_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,17 @@ get_chunk(void)
}

if (AO_EXPECT_FALSE(my_chunk_ptr - AO_initial_heap
> AO_INITIAL_HEAP_SIZE - CHUNK_SIZE))
> AO_INITIAL_HEAP_SIZE - CHUNK_SIZE)) {
/* We failed. The initial heap is used up. */
my_chunk_ptr = get_mmaped(CHUNK_SIZE);
assert(((AO_t)my_chunk_ptr & (ALIGNMENT-1)) == 0);
break;
}
if (AO_compare_and_swap(&initial_heap_ptr, (AO_t)my_chunk_ptr,
(AO_t)(my_chunk_ptr + CHUNK_SIZE))) {
return my_chunk_ptr;
break;
}
}

/* We failed. The initial heap is used up. */
my_chunk_ptr = get_mmaped(CHUNK_SIZE);
assert (!((AO_t)my_chunk_ptr & (ALIGNMENT-1)));
return my_chunk_ptr;
}

Expand Down

0 comments on commit 71d1c4d

Please sign in to comment.