Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Another batch of pointer-to-const (sonar).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jun 2022 07:58:05 +0000 (09:58 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 2 Jun 2022 07:58:05 +0000 (09:58 +0200)
examples/cpp/io-disk-raw/s4u-io-disk-raw.cpp
examples/cpp/routing-get-clusters/s4u-routing-get-clusters.cpp
src/kernel/EngineImpl.cpp
src/mc/explo/LivenessChecker.cpp
src/smpi/mpi/smpi_file.cpp
src/surf/network_ns3.cpp
teshsuite/platforms/flatifier.cpp
teshsuite/s4u/basic-parsing-test/basic-parsing-test.cpp

index 59a69e2..92958f8 100644 (file)
@@ -59,7 +59,7 @@ int main(int argc, char** argv)
   e.load_platform(argv[1]);
 
   /* - Display Host properties */
   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());
     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());
index dfa6a93..751954b 100644 (file)
@@ -18,17 +18,17 @@ int main(int argc, char* argv[])
   std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
       e.get_filtered_netzones<simgrid::kernel::routing::ClusterZone>();
 
   std::vector<simgrid::kernel::routing::ClusterZone*> clusters =
       e.get_filtered_netzones<simgrid::kernel::routing::ClusterZone>();
 
-  for (auto c : clusters) {
+  for (auto const* c : clusters) {
     XBT_INFO("%s", c->get_cname());
     std::vector<sg4::Host*> hosts = c->get_all_hosts();
     XBT_INFO("%s", c->get_cname());
     std::vector<sg4::Host*> hosts = c->get_all_hosts();
-    for (auto h : hosts)
+    for (auto const* h : hosts)
       XBT_INFO("   %s", h->get_cname());
   }
 
   std::vector<simgrid::kernel::routing::DragonflyZone*> dragonfly_clusters =
       e.get_filtered_netzones<simgrid::kernel::routing::DragonflyZone>();
 
       XBT_INFO("   %s", h->get_cname());
   }
 
   std::vector<simgrid::kernel::routing::DragonflyZone*> dragonfly_clusters =
       e.get_filtered_netzones<simgrid::kernel::routing::DragonflyZone>();
 
-  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);
     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);
index 58dccdb..7706219 100644 (file)
@@ -373,7 +373,7 @@ void EngineImpl::add_model(std::shared_ptr<resource::Model> 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());
 
   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());
   }
     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());
   }
index 461ce8a..c467eee 100644 (file)
@@ -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--) {
     // 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));
     }
       if (evaluate_label(transition_succ_label, *prop_values))
         exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ_dst, prop_values));
     }
index c6a65c8..b832510 100644 (file)
@@ -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) {
 
   // 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<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
     std::string mount;
     if (disk->get_host() != simgrid::s4u::Host::current())
       mount = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_mount_point(disk->get_host());
index cdef260..222766f 100644 (file)
@@ -145,7 +145,7 @@ static void zoneCreation_cb(simgrid::s4u::NetZone const& zone)
   double angle    = 0;
   auto nb_stations = static_cast<double>(wifizone->get_all_hosts().size() - 1);
   double step     = 2 * M_PI / nb_stations;
   double angle    = 0;
   auto nb_stations = static_cast<double>(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<NetPointNs3>();
     if (station_netpoint_ns3 == access_point_netpoint_ns3)
       continue;
     station_netpoint_ns3 = station_host->get_netpoint()->extension<NetPointNs3>();
     if (station_netpoint_ns3 == access_point_netpoint_ns3)
       continue;
index ad9ca31..451491b 100644 (file)
@@ -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(); });
 
   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("  <host id=\"%s\" speed=\"%.0f\"", h->get_cname(), h->get_speed());
     const std::unordered_map<std::string, std::string>* props = h->get_properties();
     if (h->get_core_count() > 1) {
     std::printf("  <host id=\"%s\" speed=\"%.0f\"", h->get_cname(), h->get_speed());
     const std::unordered_map<std::string, std::string>* 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(); });
 
   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("  <link id=\"");
 
     std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->get_bandwidth(),
     std::printf("  <link id=\"");
 
     std::printf("%s\" bandwidth=\"%.0f\" latency=\"%.9f\"", link->get_cname(), link->get_bandwidth(),
@@ -116,9 +116,9 @@ static void dump_routes()
               return a->get_name() < b->get_name();
             });
 
               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();
     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<simgrid::kernel::resource::StandardLinkImpl*> route;
       const simgrid::kernel::routing::NetPoint* dst = dst_host->get_netpoint();
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
       std::vector<simgrid::kernel::resource::StandardLinkImpl*> 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_ctn id=\"%s\"/>", link->get_cname());
       std::printf("\n  </route>\n");
     }
         std::printf("<link_ctn id=\"%s\"/>", link->get_cname());
       std::printf("\n  </route>\n");
     }
-    for (auto dst_host : hosts) { // Routes to host
+    for (auto const* dst_host : hosts) { // Routes to host
       std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), dst_host->get_cname());
       std::vector<simgrid::kernel::resource::StandardLinkImpl*> route;
       const simgrid::kernel::routing::NetPoint* netcardDst = dst_host->get_netpoint();
       std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), dst_host->get_cname());
       std::vector<simgrid::kernel::resource::StandardLinkImpl*> route;
       const simgrid::kernel::routing::NetPoint* netcardDst = dst_host->get_netpoint();
index 0090433..fedd092 100644 (file)
@@ -23,7 +23,7 @@ static void test_one_link(const std::vector<sg4::Host*>& hosts)
   h1->route_to(h2, route, &latency);
   XBT_INFO("Route size %zu", route.size());
 
   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)
     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<sg4::Host*>& hosts)
       h1->route_to(h2, route, &latency);
       XBT_INFO("  Route size %zu", route.size());
 
       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)
         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)