Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please codacy
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 25 Jun 2017 13:08:03 +0000 (15:08 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 25 Jun 2017 13:08:03 +0000 (15:08 +0200)
src/smpi/smpi_global.cpp
src/smpi/smpi_request.cpp
src/surf/lagrange.cpp
src/surf/plugins/host_energy.cpp
src/xbt/cunit.cpp
src/xbt/dict.cpp

index b7a827c..015834f 100644 (file)
@@ -550,8 +550,6 @@ int smpi_main(const char* executable, int argc, char *argv[])
   SIMIX_create_environment(argv[1]);
   SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
 
-  static std::size_t rank = 0;
-
   smpi_init_options();
 
   if (smpi_privatize_global_variables == SMPI_PRIVATIZE_DLOPEN) {
@@ -562,6 +560,7 @@ int smpi_main(const char* executable, int argc, char *argv[])
     struct stat fdin_stat;
     stat(executable_copy.c_str(), &fdin_stat);
     off_t fdin_size = fdin_stat.st_size;
+    static std::size_t rank = 0;
 
     simix_global->default_function = [executable_copy, fdin_size](std::vector<std::string> args) {
       return std::function<void()>([executable_copy, fdin_size, args] {
index ebfc570..3547243 100644 (file)
@@ -757,10 +757,10 @@ void Request::wait(MPI_Request * request, MPI_Status * status)
 int Request::waitany(int count, MPI_Request requests[], MPI_Status * status)
 {
   s_xbt_dynar_t comms; // Keep it on stack to save some extra mallocs
-  int size = 0;
   int index = MPI_UNDEFINED;
 
   if(count > 0) {
+    int size = 0;
     // Wait for a request to complete
     xbt_dynar_init(&comms, sizeof(smx_activity_t), [](void*ptr){
       intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr);
@@ -914,9 +914,10 @@ int Request::add_f() {
 }
 
 void Request::free_f(int id) {
-  char key[KEY_SIZE];
-  if(id!=MPI_FORTRAN_REQUEST_NULL)
+  if (id != MPI_FORTRAN_REQUEST_NULL) {
+    char key[KEY_SIZE];
     xbt_dict_remove(F2C::f2c_lookup(), get_key_id(key, id));
+  }
 }
 
 }
index e02b6fc..4ad25ed 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2007-2014. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -44,11 +43,9 @@ static int __check_feasible(xbt_swag_t cnst_list, xbt_swag_t var_list, int warn)
   lmm_constraint_t cnst = nullptr;
   lmm_variable_t var = nullptr;
 
-  double tmp;
-
   xbt_swag_foreach(_cnst, cnst_list) {
-  cnst = static_cast<lmm_constraint_t>(_cnst);
-    tmp = 0;
+    cnst       = static_cast<lmm_constraint_t>(_cnst);
+    double tmp = 0;
     elem_list = &(cnst->enabled_element_set);
     xbt_swag_foreach(_elem, elem_list) {
       elem = static_cast<lmm_element_t>(_elem);
@@ -431,30 +428,25 @@ static double dichotomy(double init, double diff(double, void *), void *var_cnst
 
 static double partial_diff_lambda(double lambda, void *param_cnst)
 {
-  int j;
-  void *_elem;
-  xbt_swag_t elem_list = nullptr;
-  lmm_element_t elem = nullptr;
-  lmm_variable_t var = nullptr;
   lmm_constraint_t cnst = static_cast<lmm_constraint_t>(param_cnst);
   double diff = 0.0;
-  double sigma_i = 0.0;
 
   XBT_IN();
-  elem_list = &(cnst->enabled_element_set);
 
   XBT_CDEBUG(surf_lagrange_dichotomy, "Computing diff of cnst (%p)", cnst);
 
+  xbt_swag_t elem_list = &(cnst->enabled_element_set);
+  void* _elem;
   xbt_swag_foreach(_elem, elem_list) {
-  elem = static_cast<lmm_element_t>(_elem);
-    var = elem->variable;
+    lmm_element_t elem = static_cast<lmm_element_t>(_elem);
+    lmm_variable_t var = elem->variable;
     xbt_assert(var->weight > 0);
     XBT_CDEBUG(surf_lagrange_dichotomy, "Computing sigma_i for var (%p)", var);
     // Initialize the summation variable
-    sigma_i = 0.0;
+    double sigma_i = 0.0;
 
     // Compute sigma_i
-    for (j = 0; j < var->cnsts_number; j++) {
+    for (int j = 0; j < var->cnsts_number; j++) {
       sigma_i += (var->cnsts[j].constraint)->lambda;
     }
 
index f666911..85d3d0c 100644 (file)
@@ -166,10 +166,10 @@ void HostEnergy::update()
 {
   double start_time  = this->last_updated;
   double finish_time = surf_get_clock();
-  double cpu_load;
   double current_speed = host->speed();
 
   if (start_time < finish_time) {
+    double cpu_load;
     // We may have start == finish if the past consumption was updated since the simcall was started
     // for example if 2 actors requested to update the same host's consumption in a given scheduling round.
     //
index 0983062..8008c3e 100644 (file)
@@ -250,7 +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_unit;
   unsigned int it_test;
 
   if (suite == nullptr)
@@ -276,6 +275,7 @@ static int xbt_test_suite_run(xbt_test_suite_t suite, int verbosity)
 
   if (suite->enabled) {
     /* iterate through all tests */
+    unsigned int it_unit;
     xbt_dynar_foreach(suite->units, it_unit, unit) {
       /* init unit case counters */
       unit->nb_tests = 0;
index f5759cf..ccc2d35 100644 (file)
@@ -72,20 +72,15 @@ xbt_dict_t xbt_dict_new_homogeneous(void_f_pvoid_t free_ctn)
  */
 void xbt_dict_free(xbt_dict_t * dict)
 {
-  xbt_dictelm_t current;
-  xbt_dictelm_t previous;
-  int table_size;
-  xbt_dictelm_t *table;
-
-  //  if ( *dict )  xbt_dict_dump_sizes(*dict);
-
   if (dict != nullptr && *dict != nullptr) {
-    table_size = (*dict)->table_size;
-    table = (*dict)->table;
+    int table_size       = (*dict)->table_size;
+    xbt_dictelm_t* table = (*dict)->table;
     /* Warning: the size of the table is 'table_size+1'...
      * This is because table_size is used as a binary mask in xbt_dict_rehash */
     for (int i = 0; (*dict)->count && i <= table_size; i++) {
-      current = table[i];
+      xbt_dictelm_t current = table[i];
+      xbt_dictelm_t previous;
+
       while (current != nullptr) {
         previous = current;
         current = current->next;