From 351f4d5661f46713d2ea8c5939144334402369a0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 2 Jun 2022 09:58:05 +0200 Subject: [PATCH] Another batch of pointer-to-const (sonar). --- examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp | 2 +- .../routing-get-clusters/s4u-routing-get-clusters.cpp | 6 +++--- src/kernel/EngineImpl.cpp | 2 +- src/mc/explo/LivenessChecker.cpp | 5 +++-- src/smpi/mpi/smpi_file.cpp | 2 +- src/surf/network_ns3.cpp | 2 +- teshsuite/platforms/flatifier.cpp | 10 +++++----- .../s4u/basic-parsing-test/basic-parsing-test.cpp | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp b/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp index 59a69e2d0c..92958f884b 100644 --- a/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp +++ b/examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp @@ -59,7 +59,7 @@ int main(int argc, char** argv) e.load_platform(argv[1]); /* - Display Host properties */ - for (auto h : e.get_all_hosts()) { + for (auto const* h : e.get_all_hosts()) { XBT_INFO("*** %s properties ****", h->get_cname()); for (auto const& [key, value] : *h->get_properties()) XBT_INFO(" %s -> %s", key.c_str(), value.c_str()); diff --git a/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp b/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp index dfa6a93a9d..751954b33a 100644 --- a/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp +++ b/examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp @@ -18,17 +18,17 @@ int main(int argc, char* argv[]) std::vector clusters = e.get_filtered_netzones(); - for (auto c : clusters) { + for (auto const* c : clusters) { XBT_INFO("%s", c->get_cname()); std::vector hosts = c->get_all_hosts(); - for (auto h : hosts) + for (auto const* h : hosts) XBT_INFO(" %s", h->get_cname()); } std::vector dragonfly_clusters = e.get_filtered_netzones(); - for (auto d : dragonfly_clusters) { + for (auto const* d : dragonfly_clusters) { XBT_INFO("%s' dragonfly topology:", d->get_cname()); for (size_t i = 0; i < d->get_host_count(); i++) { const simgrid::kernel::routing::DragonflyZone::Coords coords = d->rankId_to_coords(i); diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 58dccdbd1f..7706219d05 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -373,7 +373,7 @@ void EngineImpl::add_model(std::shared_ptr model, const std::ve xbt_assert(models_prio_.find(model_name) == models_prio_.end(), "Model %s already exists, use model.set_name() to change its name", model_name.c_str()); - for (const auto dep : dependencies) { + for (const auto* dep : dependencies) { xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(), "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str()); } diff --git a/src/mc/explo/LivenessChecker.cpp b/src/mc/explo/LivenessChecker.cpp index 461ce8a29a..c467eee9f1 100644 --- a/src/mc/explo/LivenessChecker.cpp +++ b/src/mc/explo/LivenessChecker.cpp @@ -359,8 +359,9 @@ void LivenessChecker::run() // For each enabled transition in the property automaton, push a // (application_state, automaton_state) pair to the exploration stack: for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) { - auto transition_succ_label = Api::get().get_automaton_transition_label(current_pair->automaton_state->out, i); - auto transition_succ_dst = Api::get().get_automaton_transition_dst(current_pair->automaton_state->out, i); + const auto* transition_succ_label = + Api::get().get_automaton_transition_label(current_pair->automaton_state->out, i); + auto* transition_succ_dst = Api::get().get_automaton_transition_dst(current_pair->automaton_state->out, i); if (evaluate_label(transition_succ_label, *prop_values)) exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ_dst, prop_values)); } diff --git a/src/smpi/mpi/smpi_file.cpp b/src/smpi/mpi/smpi_file.cpp index c6a65c8447..b832510aef 100644 --- a/src/smpi/mpi/smpi_file.cpp +++ b/src/smpi/mpi/smpi_file.cpp @@ -35,7 +35,7 @@ File::File(MPI_Comm comm, const char* filename, int amode, MPI_Info info) : comm // in case no fullpath is provided ... just pick the first mountpoint. if (size_t found = fullname.find('/'); found == std::string::npos || fullname.rfind("./", 1) != std::string::npos) { - auto disk = simgrid::s4u::Host::current()->get_disks().front(); + const auto* disk = simgrid::s4u::Host::current()->get_disks().front(); std::string mount; if (disk->get_host() != simgrid::s4u::Host::current()) mount = disk->extension()->get_mount_point(disk->get_host()); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index cdef2605df..222766f624 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -145,7 +145,7 @@ static void zoneCreation_cb(simgrid::s4u::NetZone const& zone) double angle = 0; auto nb_stations = static_cast(wifizone->get_all_hosts().size() - 1); double step = 2 * M_PI / nb_stations; - for (auto station_host : wifizone->get_all_hosts()) { + for (const auto* station_host : wifizone->get_all_hosts()) { station_netpoint_ns3 = station_host->get_netpoint()->extension(); if (station_netpoint_ns3 == access_point_netpoint_ns3) continue; diff --git a/teshsuite/platforms/flatifier.cpp b/teshsuite/platforms/flatifier.cpp index ad9ca31071..451491b895 100644 --- a/teshsuite/platforms/flatifier.cpp +++ b/teshsuite/platforms/flatifier.cpp @@ -50,7 +50,7 @@ static void dump_hosts() std::sort(hosts.begin(), hosts.end(), [](const sg4::Host* a, const sg4::Host* b) { return a->get_name() < b->get_name(); }); - for (auto h : hosts) { + for (auto const* h : hosts) { std::printf(" get_cname(), h->get_speed()); const std::unordered_map* props = h->get_properties(); if (h->get_core_count() > 1) { @@ -79,7 +79,7 @@ static void dump_links() std::sort(links.begin(), links.end(), [](const sg4::Link* a, const sg4::Link* b) { return a->get_name() < b->get_name(); }); - for (auto link : links) { + for (auto const* link : links) { std::printf(" get_cname(), link->get_bandwidth(), @@ -116,9 +116,9 @@ static void dump_routes() return a->get_name() < b->get_name(); }); - for (auto src_host : hosts) { // Routes from host + for (auto const* src_host : hosts) { // Routes from host const simgrid::kernel::routing::NetPoint* src = src_host->get_netpoint(); - for (auto dst_host : hosts) { // Routes to host + for (auto const* dst_host : hosts) { // Routes to host std::vector route; const simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint(); simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr); @@ -157,7 +157,7 @@ static void dump_routes() std::printf("", link->get_cname()); std::printf("\n \n"); } - for (auto dst_host : hosts) { // Routes to host + for (auto const* dst_host : hosts) { // Routes to host std::printf(" \n ", value1->get_cname(), dst_host->get_cname()); std::vector route; const simgrid::kernel::routing::NetPoint* netcardDst = dst_host->get_netpoint(); diff --git a/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp b/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp index 0090433a87..fedd092b52 100644 --- a/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp +++ b/teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp @@ -23,7 +23,7 @@ static void test_one_link(const std::vector& hosts) h1->route_to(h2, route, &latency); XBT_INFO("Route size %zu", route.size()); - for (auto link: route) { + for (auto const* link : route) { double bandwidth = link->get_bandwidth(); XBT_INFO(" Link %s: latency = %f, bandwidth = %f", link->get_cname(), link->get_latency(), bandwidth); if (bandwidth < min_bandwidth || min_bandwidth < 0.0) @@ -46,7 +46,7 @@ static void test_full_link(const std::vector& hosts) h1->route_to(h2, route, &latency); XBT_INFO(" Route size %zu", route.size()); - for (auto link: route) { + for (auto const* link : route) { double bandwidth = link->get_bandwidth(); XBT_INFO(" Link %s: latency = %f, bandwidth = %f", link->get_cname(), link->get_latency(), bandwidth); if (bandwidth < min_bandwidth || min_bandwidth < 0.0) -- 2.20.1