From: Arnaud Giersch Date: Sun, 29 Dec 2019 22:37:48 +0000 (+0100) Subject: [sonar] Constify pointer and reference parameters in src/surf/. X-Git-Tag: v3.25~190 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a0300e4fe9a9b7ab9c651651bd0456a5aab71021 [sonar] Constify pointer and reference parameters in src/surf/. --- diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index d8d97be06c..bbf5152985 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -82,7 +82,7 @@ void HostImpl::turn_off(kernel::actor::ActorImpl* issuer) } // When a host is turned off, we want to keep only the actors that should restart for when it will boot again. // Then get rid of the others. - auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](kernel::actor::ProcessArg* arg) { + auto elm = remove_if(begin(actors_at_boot_), end(actors_at_boot_), [](const kernel::actor::ProcessArg* arg) { if (arg->auto_restart) return false; delete arg; @@ -111,7 +111,7 @@ std::vector HostImpl::get_disks() return disks; } -void HostImpl::add_disk(s4u::Disk* disk) +void HostImpl::add_disk(const s4u::Disk* disk) { disks_.push_back(disk->get_impl()); } diff --git a/src/surf/HostImpl.hpp b/src/surf/HostImpl.hpp index d48e4bb14e..bb2a68d39e 100644 --- a/src/surf/HostImpl.hpp +++ b/src/surf/HostImpl.hpp @@ -52,7 +52,7 @@ public: virtual ~HostImpl(); std::vector get_disks(); - void add_disk(s4u::Disk* disk); + void add_disk(const s4u::Disk* disk); void remove_disk(const std::string& disk_name); /** @brief Get the vector of storages (by names) attached to the Host */ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 53da8a24e7..cdef36af36 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -23,7 +23,7 @@ namespace resource { * Trace * *********/ -CpuTiProfile::CpuTiProfile(profile::Profile* profile) +CpuTiProfile::CpuTiProfile(const profile::Profile* profile) { double integral = 0; double time = 0; diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 823149a421..f97ef07645 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -27,7 +27,7 @@ class XBT_PRIVATE CpuTi; *********/ class CpuTiProfile { public: - explicit CpuTiProfile(profile::Profile* profile); + explicit CpuTiProfile(const profile::Profile* profile); double integrate_simple(double a, double b); double integrate_simple_point(double a); diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 1fba58db12..f6a94c6a67 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -41,8 +41,8 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action); } -static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, simgrid::s4u::Host* src, - simgrid::s4u::Host* dst) +static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action, const simgrid::s4u::Host* src, + const simgrid::s4u::Host* dst) { simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model; simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(src->get_name()); diff --git a/src/surf/network_wifi.cpp b/src/surf/network_wifi.cpp index f7b761fbcc..6ea10384b6 100644 --- a/src/surf/network_wifi.cpp +++ b/src/surf/network_wifi.cpp @@ -27,14 +27,14 @@ NetworkWifiLink::NetworkWifiLink(NetworkCm02Model* model, const std::string& nam simgrid::s4u::Link::on_creation(*get_iface()); } -void NetworkWifiLink::set_host_rate(s4u::Host* host, int rate_level) +void NetworkWifiLink::set_host_rate(const s4u::Host* host, int rate_level) { auto insert_done = host_rates_.insert(std::make_pair(host->get_name(), rate_level)); if (insert_done.second == false) insert_done.first->second = rate_level; } -double NetworkWifiLink::get_host_rate(sg_host_t host) +double NetworkWifiLink::get_host_rate(const s4u::Host* host) { std::map::iterator host_rates_it; host_rates_it = host_rates_.find(host->get_name()); diff --git a/src/surf/network_wifi.hpp b/src/surf/network_wifi.hpp index c84527bfc3..4092d12c0b 100644 --- a/src/surf/network_wifi.hpp +++ b/src/surf/network_wifi.hpp @@ -30,9 +30,9 @@ public: NetworkWifiLink(NetworkCm02Model* model, const std::string& name, std::vector bandwidths, lmm::System* system); - void set_host_rate(s4u::Host* host, int rate_level); + void set_host_rate(const s4u::Host* host, int rate_level); /** @brief Get the AP rate associated to the host (or -1 if not associated to the AP) */ - double get_host_rate(s4u::Host* host); + double get_host_rate(const s4u::Host* host); s4u::Link::SharingPolicy get_sharing_policy() override; void apply_event(kernel::profile::Event*, double) override { THROW_UNIMPLEMENTED; } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 6247def36c..5b3db6164e 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -116,7 +116,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, return netpoint; } -static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name) +static void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link, const std::string& link_name) { simgrid::kernel::resource::LinkImpl* l = surf_network_model->create_link(link_name, link->bandwidths, link->latency, link->policy); @@ -133,7 +133,7 @@ static void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link, l->set_state_profile(link->state_trace); } -void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link) +void sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link) { if (link->policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) { sg_platf_new_link(link, link->id + "_UP"); @@ -309,7 +309,7 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb) XBT_DEBUG("Add a backbone to AS '%s'", current_routing->get_cname()); } -void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet) +void sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet) { for (int const& radical : *cabinet->radicals) { std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix; @@ -336,7 +336,7 @@ void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet delete cabinet->radicals; } -simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk) +simgrid::kernel::resource::DiskImpl* sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk) { simgrid::kernel::resource::DiskImpl* d = surf_disk_model->createDisk(disk->id, disk->read_bw, disk->write_bw); if (disk->properties) { @@ -386,7 +386,7 @@ void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage } } -void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type) +void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type) { xbt_assert(storage_types.find(storage_type->id) == storage_types.end(), "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str()); @@ -493,7 +493,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) } } -void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer) +void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer) { simgrid::kernel::routing::VivaldiZone* as = dynamic_cast(current_routing); xbt_assert(as, " tag can only be used in Vivaldi netzones."); @@ -565,7 +565,7 @@ static void surf_config_models_setup() * * @param zone the parameters defining the Zone to build. */ -simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone) +simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone) { if (not surf_parse_models_setup_already_called) { simgrid::s4u::Engine::on_platform_creation(); @@ -641,7 +641,7 @@ simgrid::kernel::routing::NetZoneImpl* sg_platf_new_Zone_begin(simgrid::kernel:: return new_zone; } -void sg_platf_new_Zone_set_properties(std::unordered_map* props) +void sg_platf_new_Zone_set_properties(const std::unordered_map* props) { xbt_assert(current_routing, "Cannot set properties of the current Zone: none under construction"); @@ -664,7 +664,7 @@ void sg_platf_new_Zone_seal() } /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */ -void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink) +void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink) { simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint(); xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str()); diff --git a/src/surf/xml/platf_private.hpp b/src/surf/xml/platf_private.hpp index fb0c3f092d..61200512df 100644 --- a/src/surf/xml/platf_private.hpp +++ b/src/surf/xml/platf_private.hpp @@ -199,16 +199,20 @@ void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb); /*** END of the parsing cruft ***/ XBT_PUBLIC simgrid::kernel::routing::NetZoneImpl* -sg_platf_new_Zone_begin(simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone -XBT_PUBLIC void sg_platf_new_Zone_set_properties(std::unordered_map* props); +sg_platf_new_Zone_begin(const simgrid::kernel::routing::ZoneCreationArgs* zone); // Begin description of new Zone +XBT_PUBLIC void sg_platf_new_Zone_set_properties(const std::unordered_map* props); XBT_PUBLIC void sg_platf_new_Zone_seal(); // That Zone is fully described XBT_PUBLIC void sg_platf_new_host(simgrid::kernel::routing::HostCreationArgs* host); // Add a host to the current Zone -XBT_PUBLIC void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone -XBT_PUBLIC void sg_platf_new_link(simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone -XBT_PUBLIC void sg_platf_new_peer(simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone +XBT_PUBLIC void +sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* h); // Add a host_link to the current Zone +XBT_PUBLIC void +sg_platf_new_link(const simgrid::kernel::routing::LinkCreationArgs* link); // Add a link to the current Zone +XBT_PUBLIC void +sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer); // Add a peer to the current Zone XBT_PUBLIC void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* clust); // Add a cluster to the current Zone -XBT_PUBLIC void sg_platf_new_cabinet(simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone +XBT_PUBLIC void +sg_platf_new_cabinet(const simgrid::kernel::routing::CabinetCreationArgs* cabinet); // Add a cabinet to the current Zone XBT_PUBLIC simgrid::kernel::routing::NetPoint* // Add a router to the current Zone sg_platf_new_router(const std::string&, const char* coords); @@ -218,10 +222,10 @@ XBT_PUBLIC void sg_platf_new_bypassRoute(simgrid::kernel::routing::RouteCreation XBT_PUBLIC void sg_platf_new_trace(simgrid::kernel::routing::ProfileCreationArgs* trace); XBT_PUBLIC simgrid::kernel::resource::DiskImpl* -sg_platf_new_disk(simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host +sg_platf_new_disk(const simgrid::kernel::routing::DiskCreationArgs* disk); // Add a disk to the current host XBT_PUBLIC void sg_platf_new_storage(simgrid::kernel::routing::StorageCreationArgs* storage); // Add a storage to the current Zone -XBT_PUBLIC void sg_platf_new_storage_type(simgrid::kernel::routing::StorageTypeCreationArgs* storage_type); +XBT_PUBLIC void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreationArgs* storage_type); XBT_PUBLIC void sg_platf_new_mount(simgrid::kernel::routing::MountCreationArgs* mount); XBT_PUBLIC void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor); diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index 2cd4006951..d2320a31a5 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -55,7 +55,7 @@ void surf_parse_assert_netpoint(const std::string& hostname, const std::string& std::vector netpoints = simgrid::s4u::Engine::get_instance()->get_all_netpoints(); std::sort(netpoints.begin(), netpoints.end(), - [](simgrid::kernel::routing::NetPoint* a, simgrid::kernel::routing::NetPoint* b) { + [](const simgrid::kernel::routing::NetPoint* a, const simgrid::kernel::routing::NetPoint* b) { return a->get_name() < b->get_name(); }); bool first = true;