From 76af4f8d5d8f11687e093dd5f2c7f94c16e51387 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sat, 2 Oct 2021 14:10:26 +0200 Subject: [PATCH] Use 'auto' with functions returning iterators [sonar]. --- src/kernel/activity/CommImpl.cpp | 8 ++++---- src/smpi/internals/smpi_config.cpp | 4 ++-- src/smpi/internals/smpi_utils.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 9b57df5743..fc67a922c8 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -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_); diff --git a/src/smpi/internals/smpi_config.cpp b/src/smpi/internals/smpi_config.cpp index a79eaed1c8..0414512df8 100644 --- a/src/smpi/internals/smpi_config.cpp +++ b/src/smpi/internals/smpi_config.cpp @@ -99,8 +99,8 @@ simgrid::config::Flag _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(location, std::stod(*end))); diff --git a/src/smpi/internals/smpi_utils.cpp b/src/smpi/internals/smpi_utils.cpp index 50f0ee8c7b..16fe5b5cff 100644 --- a/src/smpi/internals/smpi_utils.cpp +++ b/src/smpi/internals/smpi_utils.cpp @@ -65,14 +65,14 @@ std::vector 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 */ -- 2.20.1