summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-10-19 21:13:19 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-10-19 21:15:02 +0300
commit71d1c4df4b297b7707b30f84e2a2a026a6e4b345 (patch)
tree012504e84d650953ee164ef01e11e0213c43cf9e /src
parentcbde60d527fd0792b31468ab9eb2027c08573366 (diff)
downloadlibatomic_ops-71d1c4df4b297b7707b30f84e2a2a026a6e4b345.tar.gz
Workaround 'condition my_chunk_ptr is always false' cppcheck false positive
* src/atomic_ops_malloc.c (get_chunk): Move get_mmaped() call into the for loop; replace return statement inside the loop with break.
Diffstat (limited to 'src')
-rw-r--r--src/atomic_ops_malloc.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/atomic_ops_malloc.c b/src/atomic_ops_malloc.c
index 7e4bbb3..955ff22 100644
--- a/src/atomic_ops_malloc.c
+++ b/src/atomic_ops_malloc.c
@@ -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;
}