Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
codacy treats
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 17 Jul 2017 10:10:01 +0000 (12:10 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 17 Jul 2017 10:10:01 +0000 (12:10 +0200)
src/mc/compare.cpp
src/smpi/smpi_comm.cpp
src/surf/maxmin.cpp
src/surf/surf_c_bindings.cpp
src/xbt/cunit.cpp
src/xbt/dynar.cpp
teshsuite/surf/surf_usage2/surf_usage2.cpp

index fdc6c5c..1fe48f4 100644 (file)
@@ -1479,11 +1479,9 @@ static int compare_global_variables(
                (char *) current_var.address);
       return 1;
     }
-
   }
 
   return 0;
-
 }
 
 static int compare_local_variables(simgrid::mc::StateComparator& state,
@@ -1500,7 +1498,6 @@ static int compare_local_variables(simgrid::mc::StateComparator& state,
 
     unsigned int cursor = 0;
     local_variable_t current_var1, current_var2;
-    int res;
     while (cursor < stack1->local_variables.size()) {
       current_var1 = &stack1->local_variables[cursor];
       current_var2 = &stack1->local_variables[cursor];
@@ -1521,22 +1518,18 @@ static int compare_local_variables(simgrid::mc::StateComparator& state,
       // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
 
         simgrid::mc::Type* subtype = current_var1->type;
-        res =
-            compare_areas_with_type(state, process_index,
-                                    current_var1->address, snapshot1, mc_get_snapshot_region(current_var1->address, snapshot1, process_index),
-                                    current_var2->address, snapshot2, mc_get_snapshot_region(current_var2->address, snapshot2, process_index),
-                                    subtype, 0);
-
-      if (res == 1) {
-        // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
-        XBT_VERB
-            ("Local variable %s (%p - %p) in frame %s "
-             "is different between snapshots",
-             current_var1->name.c_str(),
-             current_var1->address,
-             current_var2->address,
-             current_var1->subprogram->name.c_str());
-        return res;
+        int res                    = compare_areas_with_type(
+            state, process_index, current_var1->address, snapshot1,
+            mc_get_snapshot_region(current_var1->address, snapshot1, process_index), current_var2->address, snapshot2,
+            mc_get_snapshot_region(current_var2->address, snapshot2, process_index), subtype, 0);
+
+        if (res == 1) {
+          // TODO, fix current_varX->subprogram->name to include name if DW_TAG_inlined_subprogram
+          XBT_VERB("Local variable %s (%p - %p) in frame %s "
+                   "is different between snapshots",
+                   current_var1->name.c_str(), current_var1->address, current_var2->address,
+                   current_var1->subprogram->name.c_str());
+          return res;
       }
       cursor++;
     }
index 857fc9a..23de66f 100644 (file)
@@ -423,11 +423,10 @@ void Comm::init_smp(){
     smpi_process()->set_comm_intra(comm_intra);
   }
 
-  int is_uniform = 1;
-
   // Are the nodes uniform ? = same number of process/node
   int my_local_size=comm_intra->size();
   if(comm_intra->rank()==0) {
+    int is_uniform       = 1;
     int* non_uniform_map = xbt_new0(int,leader_group_size);
     Coll_allgather_mpich::allgather(&my_local_size, 1, MPI_INT,
         non_uniform_map, 1, MPI_INT, leader_comm);
index f6dfe9a..a444396 100644 (file)
@@ -460,7 +460,6 @@ void lmm_expand(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, dou
 void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, double value)
 {
   int i;
-  double weight;
   sys->modified = 1;
 
   lmm_check_concurrency(sys);
@@ -482,7 +481,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var,
     //We need to check that increasing value of the element does not cross the concurrency limit
     if (var->sharing_weight) {
       if(lmm_concurrency_slack(cnst)<lmm_element_concurrency(&var->cnsts[i])){
-        weight = var->sharing_weight;
+        double weight = var->sharing_weight;
         lmm_disable_var(sys,var);
         for (int j = 0; j < var->cnsts_number; j++)
           lmm_on_disabled_var(sys,var->cnsts[j].constraint);
index 97e7964..46f00de 100644 (file)
@@ -41,7 +41,6 @@ void surf_presolve()
 double surf_solve(double max_date)
 {
   double time_delta = -1.0; /* duration */
-  double next_event_date = -1.0;
   double model_next_action_end = -1.0;
   double value = -1.0;
   simgrid::surf::Resource *resource = nullptr;
@@ -71,7 +70,7 @@ double surf_solve(double max_date)
   XBT_DEBUG("Looking for next trace event");
 
   while (1) { // Handle next occurring events until none remains
-    next_event_date = future_evt_set->next_date();
+    double next_event_date = future_evt_set->next_date();
     XBT_DEBUG("Next TRACE event: %f", next_event_date);
 
     if (not surf_network_model->nextOccuringEventIsIdempotent()) { // NS3, I see you
index 8008c3e..eac5f1a 100644 (file)
@@ -250,8 +250,6 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity)
   xbt_test_test_t test;
   xbt_test_log_t log;
 
-  unsigned int it_test;
-
   if (suite == nullptr)
     return 0;
 
@@ -297,6 +295,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity)
         unit->func();
 
       /* iterate through all performed tests to determine status */
+      unsigned int it_test;
       xbt_dynar_foreach(unit->tests, it_test, test) {
         if (test->ignored) {
           unit->test_ignore++;
index b1a20fd..cef1231 100644 (file)
@@ -393,9 +393,6 @@ extern "C" void xbt_dynar_remove_at(xbt_dynar_t const dynar, const int idx, void
  */
 extern "C" void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned int n, const int idx)
 {
-  unsigned long nb_shift;
-  unsigned long offset;
-
   if (not n)
     return;
 
@@ -409,10 +406,10 @@ extern "C" void xbt_dynar_remove_n_at(xbt_dynar_t const dynar, const unsigned in
     }
   }
 
-  nb_shift = dynar->used - n - idx;
+  unsigned long nb_shift = dynar->used - n - idx;
 
   if (nb_shift) {
-    offset = nb_shift * dynar->elmsize;
+    unsigned long offset = nb_shift * dynar->elmsize;
     memmove(_xbt_dynar_elm(dynar, idx), _xbt_dynar_elm(dynar, idx + n), offset);
   }
 
index 1ce4276..0b0f8af 100644 (file)
@@ -13,7 +13,6 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
 
 int main(int argc, char **argv)
 {
-  double now = -1.0;
   int running;
 
   surf_init(&argc, argv);       /* Initialize some common structures */
@@ -40,7 +39,7 @@ int main(int argc, char **argv)
     surf_action_t action = nullptr;
     running = 0;
 
-    now = surf_get_clock();
+    double now = surf_get_clock();
     XBT_INFO("Next Event : %g", now);
 
     for (auto model: *all_existing_models) {