Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
minor smell--
[simgrid.git] / src / mc / compare.cpp
index eef1ca8..1093b18 100644 (file)
 #include "src/xbt/mmalloc/mmprivate.h"
 
 #if HAVE_SMPI
-#include "src/smpi/include/private.h"
 #include "src/smpi/include/private.hpp"
 #endif
 
-#include "src/mc/mc_forward.hpp"
-#include "src/mc/mc_private.h"
-#include "src/mc/mc_smx.h"
-#include "src/mc/mc_dwarf.hpp"
 #include "src/mc/Frame.hpp"
 #include "src/mc/ObjectInformation.hpp"
+#include "src/mc/Type.hpp"
 #include "src/mc/Variable.hpp"
-#include "src/mc/mc_private.h"
-#include "src/mc/mc_snapshot.h"
 #include "src/mc/mc_dwarf.hpp"
-#include "src/mc/Type.hpp"
+#include "src/mc/mc_forward.hpp"
+#include "src/mc/mc_private.hpp"
+#include "src/mc/mc_smx.hpp"
+#include "src/mc/mc_snapshot.hpp"
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, xbt, "Logging specific to mc_compare in mc");
 
@@ -131,8 +128,8 @@ template <class X, class Y> class hash<std::pair<X, Y>> {
 public:
   std::size_t operator()(std::pair<X,Y>const& x) const
   {
-    struct hash<X> h1;
-    struct hash<X> h2;
+    hash<X> h1;
+    hash<X> h2;
     return h1(x.first) ^ h2(x.second);
   }
 };
@@ -441,7 +438,6 @@ int mmalloc_compare_heap(
         XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1);
         i1 = state.heaplimit + 1;
         nb_diff1++;
-        //i1++;
       }
 
     } else {                    /* Fragmented block */
@@ -983,7 +979,8 @@ int compare_heap_area(simgrid::mc::StateComparator& state, int process_index,
   const malloc_info* heapinfos1 = snapshot1->read(remote((const malloc_info**)heapinfo_address), process_index);
   const malloc_info* heapinfos2 = snapshot2->read(remote((const malloc_info**)heapinfo_address), process_index);
 
-  malloc_info heapinfo_temp1, heapinfo_temp2;
+  malloc_info heapinfo_temp1;
+  malloc_info heapinfo_temp2;
 
   simgrid::mc::HeapLocationPairs current;
   if (previous == nullptr) {
@@ -1339,40 +1336,34 @@ static int compare_areas_with_type(simgrid::mc::StateComparator& state,
 
     pointer_level++;
 
-      // Some cases are not handled here:
-      // * the pointers lead to different areas (one to the heap, the other to the RW segment ...);
-      // * a pointer leads to the read-only segment of the current object;
-      // * a pointer lead to a different ELF object.
-
-      if (addr_pointed1 > process->heap_address
-          && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)) {
-        if (not(addr_pointed2 > process->heap_address && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
-          return 1;
-        // The pointers are both in the heap:
-        return simgrid::mc::compare_heap_area(state,
-          process_index, addr_pointed1, addr_pointed2, snapshot1,
-          snapshot2, nullptr, type->subtype, pointer_level);
-      }
+    // Some cases are not handled here:
+    // * the pointers lead to different areas (one to the heap, the other to the RW segment ...)
+    // * a pointer leads to the read-only segment of the current object
+    // * a pointer lead to a different ELF object
+
+    if (addr_pointed1 > process->heap_address && addr_pointed1 < mc_snapshot_get_heap_end(snapshot1)) {
+      if (not(addr_pointed2 > process->heap_address && addr_pointed2 < mc_snapshot_get_heap_end(snapshot2)))
+        return 1;
+      // The pointers are both in the heap:
+      return simgrid::mc::compare_heap_area(state, process_index, addr_pointed1, addr_pointed2, snapshot1, snapshot2,
+                                            nullptr, type->subtype, pointer_level);
 
+    } else if (region1->contain(simgrid::mc::remote(addr_pointed1))) {
       // The pointers are both in the current object R/W segment:
-      else if (region1->contain(simgrid::mc::remote(addr_pointed1))) {
-        if (not region2->contain(simgrid::mc::remote(addr_pointed2)))
-          return 1;
-        if (not type->type_id)
-          return (addr_pointed1 != addr_pointed2);
-        else
-          return compare_areas_with_type(state, process_index,
-                                         addr_pointed1, snapshot1, region1,
-                                         addr_pointed2, snapshot2, region2,
-                                         type->subtype, pointer_level);
-      }
+      if (not region2->contain(simgrid::mc::remote(addr_pointed2)))
+        return 1;
+      if (not type->type_id)
+        return (addr_pointed1 != addr_pointed2);
+      else
+        return compare_areas_with_type(state, process_index, addr_pointed1, snapshot1, region1, addr_pointed2,
+                                       snapshot2, region2, type->subtype, pointer_level);
+    } else {
 
       // TODO, We do not handle very well the case where
       // it belongs to a different (non-heap) region from the current one.
 
-      else
-        return (addr_pointed1 != addr_pointed2);
-
+      return (addr_pointed1 != addr_pointed2);
+    }
     break;
   }
   case DW_TAG_structure_type:
@@ -1479,7 +1470,8 @@ static int compare_local_variables(simgrid::mc::StateComparator& state,
   }
 
     unsigned int cursor = 0;
-    local_variable_t current_var1, current_var2;
+    local_variable_t current_var1;
+    local_variable_t current_var2;
     while (cursor < stack1->local_variables.size()) {
       current_var1 = &stack1->local_variables[cursor];
       current_var2 = &stack1->local_variables[cursor];