Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use 'auto' with functions returning iterators [sonar].
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Oct 2021 12:10:26 +0000 (14:10 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 2 Oct 2021 19:12:37 +0000 (21:12 +0200)
src/kernel/activity/CommImpl.cpp
src/smpi/internals/smpi_config.cpp
src/smpi/internals/smpi_utils.cpp

index 9b57df5..fc67a92 100644 (file)
@@ -579,8 +579,8 @@ void CommImpl::finish()
         simcall->timeout_cb_ = nullptr;
       }
       if (not MC_is_active() && not MC_record_replay_is_active()) {
-        CommImpl** element = std::find(comms, comms + count, this);
-        ssize_t rank       = (element != comms + count) ? element - comms : -1;
+        auto element = std::find(comms, comms + count, this);
+        ssize_t rank = (element != comms + count) ? element - comms : -1;
         simcall_comm_waitany__set__result(simcall, rank);
       }
     }
@@ -672,8 +672,8 @@ void CommImpl::finish()
         comms = simcall_comm_testany__get__comms(simcall);
         count = simcall_comm_testany__get__count(simcall);
       }
-      CommImpl** element = std::find(comms, comms + count, this);
-      ssize_t rank       = (element != comms + count) ? element - comms : -1;
+      auto element = std::find(comms, comms + count, this);
+      ssize_t rank = (element != comms + count) ? element - comms : -1;
       // In order to modify the exception we have to rethrow it:
       try {
         std::rethrow_exception(simcall->issuer_->exception_);
index a79eaed..0414512 100644 (file)
@@ -99,8 +99,8 @@ simgrid::config::Flag<std::string> _smpi_cfg_comp_adjustment_file{"smpi/comp-adj
         std::getline(fstream, line); // Skip the header line
         while (std::getline(fstream, line)) {
           Tokenizer tok(line);
-          Tokenizer::iterator it  = tok.begin();
-          Tokenizer::iterator end = std::next(tok.begin());
+          auto it              = tok.begin();
+          auto end             = std::next(tok.begin());
           std::string location = *it;
           boost::trim(location);
           location2speedup.insert(std::pair<std::string, double>(location, std::stod(*end)));
index 50f0ee8..16fe5b5 100644 (file)
@@ -65,14 +65,14 @@ std::vector<s_smpi_factor_t> parse_factor(const std::string& smpi_coef_string)
    * E --> F
    * G --> H
    */
-  for (Tokenizer::iterator token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) {
+  for (auto token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) {
     XBT_DEBUG("token: %s", token_iter->c_str());
     Tokenizer factor_values(*token_iter, factor_separator);
     s_smpi_factor_t fact;
     xbt_assert(factor_values.begin() != factor_values.end(), "Malformed radical for smpi factor: '%s'",
                smpi_coef_string.c_str());
     unsigned int iteration = 0;
-    for (Tokenizer::iterator factor_iter = factor_values.begin(); factor_iter != factor_values.end(); ++factor_iter) {
+    for (auto factor_iter = factor_values.begin(); factor_iter != factor_values.end(); ++factor_iter) {
       iteration++;
 
       if (factor_iter == factor_values.begin()) { /* first element */