]> granicus.if.org Git - libatomic_ops/commitdiff
Workaround 'condition my_chunk_ptr is always false' cppcheck false positive
authorIvan Maidanski <ivmai@mail.ru>
Fri, 19 Oct 2018 18:13:19 +0000 (21:13 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 19 Oct 2018 18:15:02 +0000 (21:15 +0300)
* src/atomic_ops_malloc.c (get_chunk): Move get_mmaped() call into the
for loop; replace return statement inside the loop with break.

src/atomic_ops_malloc.c

index 7e4bbb3f07e9de1ffc85b0662d6435e28d73e052..955ff22567e50a35cb8dde1c7137716ba4d6a312 100644 (file)
@@ -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;
 }