Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Preserve const qualifier with cast.
[simgrid.git] / src / mc / compare.cpp
index e8457a3..f302e81 100644 (file)
@@ -254,10 +254,7 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
       continue;
     }
 
-    if (heapinfo1->type < 0) {
-      fprintf(stderr, "Unkown mmalloc block type.\n");
-      abort();
-    }
+    xbt_assert(heapinfo1->type >= 0, "Unkown mmalloc block type: %d", heapinfo1->type);
 
     void* addr_block1 = ((void*)(((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase));
 
@@ -371,10 +368,7 @@ static bool mmalloc_heap_differ(simgrid::mc::StateComparator& state, const simgr
             continue;
           }
 
-          if (heapinfo2b->type < 0) {
-            fprintf(stderr, "Unknown mmalloc block type.\n");
-            abort();
-          }
+          xbt_assert(heapinfo2b->type >= 0, "Unkown mmalloc block type: %d", heapinfo2b->type);
 
           for (size_t j2 = 0; j2 < (size_t)(BLOCKSIZE >> heapinfo2b->type); j2++) {
 
@@ -495,8 +489,8 @@ static bool heap_area_differ_without_type(simgrid::mc::StateComparator& state, c
                                   1) != 0) {
 
       int pointer_align = (i / sizeof(void *)) * sizeof(void *);
-      const void* addr_pointed1 = snapshot1.read(remote((void**)((const char*)real_area1 + pointer_align)));
-      const void* addr_pointed2 = snapshot2.read(remote((void**)((const char*)real_area2 + pointer_align)));
+      const void* addr_pointed1 = snapshot1.read(remote((void* const*)((const char*)real_area1 + pointer_align)));
+      const void* addr_pointed2 = snapshot2.read(remote((void* const*)((const char*)real_area2 + pointer_align)));
 
       if (process.in_maestro_stack(remote(addr_pointed1)) && process.in_maestro_stack(remote(addr_pointed2))) {
         i = pointer_align + sizeof(void *);
@@ -695,7 +689,6 @@ static bool heap_area_differ_with_type(simgrid::mc::StateComparator& state, cons
     default:
       THROW_IMPOSSIBLE;
   }
-  return false;
 }
 
 /** Infer the type of a part of the block from the type of the block
@@ -1098,8 +1091,8 @@ static bool areas_differ_with_type(simgrid::mc::StateComparator& state, const vo
       }
       for (i = 0; i < type->element_count; i++) {
         size_t off = i * elm_size;
-        if (areas_differ_with_type(state, (char*)real_area1 + off, snapshot1, region1, (char*)real_area2 + off,
-                                   snapshot2, region2, type->subtype, pointer_level))
+        if (areas_differ_with_type(state, (const char*)real_area1 + off, snapshot1, region1,
+                                   (const char*)real_area2 + off, snapshot2, region2, type->subtype, pointer_level))
           return true;
       }
       break;