From 371d168e21b83e2364c2ac2dbff3847588769c2b Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Mon, 15 May 2023 17:12:12 +0200 Subject: [PATCH] Use plain pointers instead of references to pointer. --- examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp | 2 +- src/kernel/actor/CommObserver.cpp | 8 ++++---- src/kernel/resource/VirtualMachineImpl.cpp | 8 ++++---- src/kernel/resource/models/network_cm02.cpp | 2 +- src/kernel/resource/models/network_ns3.cpp | 2 +- src/kernel/resource/models/ptask_L07.cpp | 4 ++-- src/kernel/routing/NetZoneImpl.cpp | 4 ++-- src/kernel/xml/platf_sax_cb.cpp | 4 ++-- src/kernel/xml/sg_platf.cpp | 8 ++++---- src/plugins/host_energy.cpp | 2 +- src/plugins/vm/dirty_page_tracking.cpp | 2 +- src/smpi/mpi/smpi_f2c.cpp | 2 +- .../s4u/storage_client_server/storage_client_server.cpp | 6 +++--- teshsuite/s4u/vm-suicide/vm-suicide.cpp | 6 +++--- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp index 5386b58002..59814cdcf0 100644 --- a/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp +++ b/examples/cpp/dag-scheduling/s4u-dag-scheduling.cpp @@ -193,7 +193,7 @@ int main(int argc, char** argv) } /* Cleanup memory */ - for (auto const& h : e.get_all_hosts()) + for (auto const* h : e.get_all_hosts()) delete h->get_data(); XBT_INFO("Simulation Time: %f", simgrid_get_clock()); diff --git a/src/kernel/actor/CommObserver.cpp b/src/kernel/actor/CommObserver.cpp index 84c317e1c4..c065e2af36 100644 --- a/src/kernel/actor/CommObserver.cpp +++ b/src/kernel/actor/CommObserver.cpp @@ -68,7 +68,7 @@ static std::string to_string_activity_test(const activity::ActivityImpl* act) void ActivityTestanySimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::TESTANY << ' ' << activities_.size() << ' '; - for (auto const& act : activities_) { + for (auto const* act : activities_) { serialize_activity_test(act, stream); stream << ' '; } @@ -76,7 +76,7 @@ void ActivityTestanySimcall::serialize(std::stringstream& stream) const std::string ActivityTestanySimcall::to_string() const { std::stringstream buffer("TestAny("); - for (auto const& act : activities_) { + for (auto const* act : activities_) { buffer << to_string_activity_test(act); } return buffer.str(); @@ -127,7 +127,7 @@ void ActivityWaitSimcall::serialize(std::stringstream& stream) const void ActivityWaitanySimcall::serialize(std::stringstream& stream) const { stream << (short)mc::Transition::Type::WAITANY << ' ' << activities_.size() << ' '; - for (auto const& act : activities_) { + for (auto const* act : activities_) { serialize_activity_wait(act, timeout_ > 0, stream); stream << ' '; } @@ -139,7 +139,7 @@ std::string ActivityWaitSimcall::to_string() const std::string ActivityWaitanySimcall::to_string() const { std::stringstream buffer("WaitAny("); - for (auto const& act : activities_) { + for (auto const* act : activities_) { buffer << to_string_activity_wait(act); } return buffer.str(); diff --git a/src/kernel/resource/VirtualMachineImpl.cpp b/src/kernel/resource/VirtualMachineImpl.cpp index 1cf155fca2..04f8ada28f 100644 --- a/src/kernel/resource/VirtualMachineImpl.cpp +++ b/src/kernel/resource/VirtualMachineImpl.cpp @@ -60,10 +60,10 @@ static void host_state_change(s4u::Host const& host) if (not host.is_on()) { // just turned off. std::vector trash; /* Find all VMs living on that host */ - for (s4u::VirtualMachine* const& vm : VirtualMachineImpl::allVms_) + for (auto* vm : VirtualMachineImpl::allVms_) if (vm->get_pm() == &host) trash.push_back(vm); - for (s4u::VirtualMachine* vm : trash) + for (auto* vm : trash) vm->shutdown(); } } @@ -157,7 +157,7 @@ double VMModel::next_occurring_event(double now) **/ /* iterate for all virtual machines */ - for (s4u::VirtualMachine* const& ws_vm : VirtualMachineImpl::allVms_) { + for (auto const* ws_vm : VirtualMachineImpl::allVms_) { if (ws_vm->get_state() == s4u::VirtualMachine::State::SUSPENDED) // Ignore suspended VMs continue; @@ -249,7 +249,7 @@ void VirtualMachineImpl::start() not physical_host_->extension()->overcommit) { /* Need to verify that we don't overcommit */ /* Retrieve the memory occupied by the VMs on that host. Yep, we have to traverse all VMs of all hosts for that */ size_t total_ramsize_of_vms = 0; - for (auto* const& ws_vm : allVms_) + for (auto const* ws_vm : allVms_) if (physical_host_ == ws_vm->get_pm()) total_ramsize_of_vms += ws_vm->get_ramsize(); diff --git a/src/kernel/resource/models/network_cm02.cpp b/src/kernel/resource/models/network_cm02.cpp index 2b1e5d1337..36cc2a3a66 100644 --- a/src/kernel/resource/models/network_cm02.cpp +++ b/src/kernel/resource/models/network_cm02.cpp @@ -445,7 +445,7 @@ Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double siz if (cfg_weight_S_parameter > 0) { action->sharing_penalty_ = std::accumulate(route.begin(), route.end(), action->sharing_penalty_, - [](double total, StandardLinkImpl* const& link) { + [](double total, StandardLinkImpl const* link) { return total + cfg_weight_S_parameter / link->get_bandwidth(); }); } diff --git a/src/kernel/resource/models/network_ns3.cpp b/src/kernel/resource/models/network_ns3.cpp index 2d3ccd907d..9904d0483d 100644 --- a/src/kernel/resource/models/network_ns3.cpp +++ b/src/kernel/resource/models/network_ns3.cpp @@ -465,7 +465,7 @@ void NetworkNS3Model::update_actions_state(double now, double delta) std::vector route; action->get_src().route_to(&action->get_dst(), route, nullptr); - for (auto const& link : route) + for (auto const* link : route) instr::resource_set_utilization("LINK", "bandwidth_used", link->get_cname(), action->get_category(), data_delta_sent / delta, now - delta, delta); diff --git a/src/kernel/resource/models/ptask_L07.cpp b/src/kernel/resource/models/ptask_L07.cpp index 769292c069..eefedf3315 100644 --- a/src/kernel/resource/models/ptask_L07.cpp +++ b/src/kernel/resource/models/ptask_L07.cpp @@ -194,7 +194,7 @@ L07Action::L07Action(Model* model, const std::vector& host_list, con host_list_[k / host_nb]->route_to(host_list_[k % host_nb], route, &lat); latency = std::max(latency, lat); - for (auto const& link : route) + for (auto const* link : route) affected_links.insert(link->get_cname()); } @@ -223,7 +223,7 @@ L07Action::L07Action(Model* model, const std::vector& host_list, con std::vector route; host_list_[k / host_nb]->route_to(host_list_[k % host_nb], route, nullptr); - for (auto const& link : route) + for (auto const* link : route) model->get_maxmin_system()->expand(link->get_constraint(), this->get_variable(), bytes_amount[k]); } } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 903023329e..5ed1d62097 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -622,8 +622,8 @@ void NetZoneImpl::get_graph(const s_xbt_graph_t* graph, std::map vertices = get_vertices(); - for (auto const& my_src : vertices) { - for (auto const& my_dst : vertices) { + for (auto const* my_src : vertices) { + for (auto const* my_dst : vertices) { if (my_src == my_dst) continue; diff --git a/src/kernel/xml/platf_sax_cb.cpp b/src/kernel/xml/platf_sax_cb.cpp index 23528c0cad..82f8bcefc2 100644 --- a/src/kernel/xml/platf_sax_cb.cpp +++ b/src/kernel/xml/platf_sax_cb.cpp @@ -535,7 +535,7 @@ void ETag_simgrid_parse_link() void STag_simgrid_parse_link___ctn() { - const auto engine = simgrid::s4u::Engine::get_instance(); + const auto* engine = simgrid::s4u::Engine::get_instance(); const simgrid::s4u::Link* link; simgrid::s4u::LinkInRoute::Direction direction = simgrid::s4u::LinkInRoute::Direction::NONE; switch (A_simgrid_parse_link___ctn_direction) { @@ -957,7 +957,7 @@ void simgrid_parse(bool fire_on_platform_created_callback_param) simgrid_parse_assert(not err, "Flex returned an error code"); /* Actually connect the traces now that every elements are created */ - const auto engine = simgrid::s4u::Engine::get_instance(); + const auto* engine = simgrid::s4u::Engine::get_instance(); for (auto const& [trace, name] : trace_connect_list_host_avail) { simgrid_parse_assert(traces_set_list.find(trace) != traces_set_list.end(), diff --git a/src/kernel/xml/sg_platf.cpp b/src/kernel/xml/sg_platf.cpp index 1b2055de36..0d64feb5ab 100644 --- a/src/kernel/xml/sg_platf.cpp +++ b/src/kernel/xml/sg_platf.cpp @@ -373,12 +373,12 @@ static void sg_platf_build_hostlink(simgrid::kernel::routing::StarZone* zone, const simgrid::kernel::routing::HostLinkCreationArgs* hostlink, const simgrid::s4u::Link* backbone) { - const auto engine = simgrid::s4u::Engine::get_instance(); - auto netpoint = engine->host_by_name(hostlink->id)->get_netpoint(); + const auto* engine = simgrid::s4u::Engine::get_instance(); + auto* netpoint = engine->host_by_name(hostlink->id)->get_netpoint(); xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str()); - const auto linkUp = engine->link_by_name_or_null(hostlink->link_up); - const auto linkDown = engine->link_by_name_or_null(hostlink->link_down); + const auto* linkUp = engine->link_by_name_or_null(hostlink->link_up); + const auto* linkDown = engine->link_by_name_or_null(hostlink->link_down); xbt_assert(linkUp, "Link '%s' not found!", hostlink->link_up.c_str()); xbt_assert(linkDown, "Link '%s' not found!", hostlink->link_down.c_str()); diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 2bf95b1065..36e10449cf 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -420,7 +420,7 @@ static void on_creation(simgrid::s4u::Host& host) static void on_action_state_change(simgrid::kernel::resource::CpuAction const& action, simgrid::kernel::resource::Action::State /*previous*/) { - for (simgrid::kernel::resource::CpuImpl* const& cpu : action.cpus()) { + for (simgrid::kernel::resource::CpuImpl const* cpu : action.cpus()) { simgrid::s4u::Host* host = cpu->get_iface(); if (host != nullptr) { // If it's a VM, take the corresponding PM diff --git a/src/plugins/vm/dirty_page_tracking.cpp b/src/plugins/vm/dirty_page_tracking.cpp index d5a74434a8..0f90d30255 100644 --- a/src/plugins/vm/dirty_page_tracking.cpp +++ b/src/plugins/vm/dirty_page_tracking.cpp @@ -90,7 +90,7 @@ static void on_exec_creation(simgrid::s4u::Exec const& e) static void on_exec_completion(const simgrid::s4u::Activity& e) { - const auto exec = dynamic_cast(e.get_impl()); + const auto* exec = dynamic_cast(e.get_impl()); if (exec == nullptr) return; const simgrid::s4u::VirtualMachine* vm = dynamic_cast(exec->get_host()); diff --git a/src/smpi/mpi/smpi_f2c.cpp b/src/smpi/mpi/smpi_f2c.cpp index bdec55b5a2..a1e6be788b 100644 --- a/src/smpi/mpi/smpi_f2c.cpp +++ b/src/smpi/mpi/smpi_f2c.cpp @@ -25,7 +25,7 @@ F2C::F2C() = default; int F2C::add_f() { allocate_lookup(); - if (auto loc = smpi_process()->call_location(); loc && loc->linenumber != 0) + if (auto const* loc = smpi_process()->call_location(); loc && loc->linenumber != 0) call_location_= std::string (loc->filename + ":" + std::to_string(loc->linenumber)); my_f2c_id_ = global_f2c_id(); (*f2c_lookup_)[my_f2c_id_] = this; diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index 9439fc2c6d..351c4e4b75 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -86,8 +86,8 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk) static void dump_platform_disks() { - for (auto const& h : simgrid::s4u::Engine::get_instance()->get_all_hosts()) - for (auto const& d : h->get_disks()) { + for (auto const* h : simgrid::s4u::Engine::get_instance()->get_all_hosts()) + for (auto* d : h->get_disks()) { if (h == d->get_host()) XBT_INFO("%s is attached to %s", d->get_cname(), d->get_host()->get_cname()); d->set_property("other usage", "gpfs"); @@ -98,7 +98,7 @@ static void disk_info(const simgrid::s4u::Host* host) { XBT_INFO("*** Disk info on %s ***", host->get_cname()); - for (auto const& disk : host->get_disks()) { + for (auto const* disk : host->get_disks()) { const char* mount_name = sg_disk_get_mount_point(disk); XBT_INFO(" Disk name: %s, mount name: %s", disk->get_cname(), mount_name); diff --git a/teshsuite/s4u/vm-suicide/vm-suicide.cpp b/teshsuite/s4u/vm-suicide/vm-suicide.cpp index 733d9a56a0..69cdf8623e 100644 --- a/teshsuite/s4u/vm-suicide/vm-suicide.cpp +++ b/teshsuite/s4u/vm-suicide/vm-suicide.cpp @@ -27,14 +27,14 @@ static void print_status(const std::vector& hosts) { XBT_INFO("---- HOSTS and VMS STATUS ----"); XBT_INFO("--- HOSTS ---"); - for (auto const& host : hosts) { + for (auto const* host : hosts) { XBT_INFO("+ Name:%s Load:%f", host->get_cname(), host->get_load()); for (auto const& actor : host->get_all_actors()) XBT_INFO("++ actor: %s", actor->get_cname()); } XBT_INFO("--- VMS ---"); - for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts()) { - if (auto vm = dynamic_cast(host)) { + for (auto const* host : simgrid::s4u::Engine::get_instance()->get_all_hosts()) { + if (auto const* vm = dynamic_cast(host)) { XBT_INFO("+ Name:%s Host:%s Load:%f State: %s", vm->get_cname(), vm->get_pm()->get_cname(), vm->get_load(), simgrid::s4u::VirtualMachine::to_c_str(vm->get_state())); for (auto const& actor : host->get_all_actors()) -- 2.20.1