Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] cleanup some recent smells
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sun, 2 Jan 2022 13:24:14 +0000 (14:24 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Sun, 2 Jan 2022 13:25:52 +0000 (14:25 +0100)
examples/cpp/engine-run-partial/s4u-engine-run-partial.cpp
examples/cpp/platform-failures/s4u-platform-failures.cpp
src/plugins/vm/dirty_page_tracking.cpp
src/simdag/sd_daxloader.cpp

index ab7df14..0cc2b4e 100644 (file)
@@ -18,37 +18,6 @@ static void runner(simgrid::s4u::ExecPtr activity)
   XBT_INFO("Goodbye now!");
 }
 
-/* This actor tests the ongoing execution until its completion, and don't wait before it's terminated. */
-static void monitor()
-{
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
-  XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_init(computation_amount);
-  activity->start();
-
-  while (not activity->test()) {
-    XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
-             100 * activity->get_remaining_ratio());
-    simgrid::s4u::this_actor::sleep_for(0.3);
-  }
-
-  XBT_INFO("Goodbye now!");
-}
-
-/* This actor cancels the ongoing execution after a while. */
-static void canceller()
-{
-  double computation_amount = simgrid::s4u::this_actor::get_host()->get_speed();
-
-  XBT_INFO("Execute %g flops, should take 1 second.", computation_amount);
-  simgrid::s4u::ExecPtr activity = simgrid::s4u::this_actor::exec_async(computation_amount);
-  simgrid::s4u::this_actor::sleep_for(0.5);
-  XBT_INFO("I changed my mind, cancel!");
-  activity->cancel();
-
-  XBT_INFO("Goodbye now!");
-}
-
 int main(int argc, char* argv[])
 {
   simgrid::s4u::Engine e(&argc, argv);
@@ -62,7 +31,7 @@ int main(int argc, char* argv[])
   while (activity->get_remaining() > 0) {
     XBT_INFO("Remaining amount of flops: %g (%.0f%%)", activity->get_remaining(),
              100 * activity->get_remaining_ratio());
-    e.run_until(e.get_clock() + 1);
+    e.run_until(simgrid::s4u::Engine::get_clock() + 1);
   }
 
   XBT_INFO("Simulation time %g", simgrid::s4u::Engine::get_clock());
index b47d78e..675e2f1 100644 (file)
@@ -116,9 +116,9 @@ int main(int argc, char* argv[])
   e.load_deployment(argv[2]);
 
   // Add a new host programatically, and attach a state profile to it
-  auto* root            = e.get_netzone_root();
-  auto* lilibeth        = root->create_host("Lilibeth", 1e15);
-  sg4::LinkInRoute link = sg4::LinkInRoute(e.link_by_name("10"));
+  auto* root     = e.get_netzone_root();
+  auto* lilibeth = root->create_host("Lilibeth", 1e15);
+  auto link      = sg4::LinkInRoute(e.link_by_name("10"));
   root->add_route(e.host_by_name("Tremblay")->get_netpoint(), lilibeth->get_netpoint(), nullptr, nullptr, {link}, true);
   lilibeth->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("lilibeth_profile", R"(
 4 0
index 466c071..ff1f087 100644 (file)
@@ -92,7 +92,7 @@ static void on_exec_creation(simgrid::s4u::Exec const& e)
   }
 }
 
-static void on_exec_completion(simgrid::s4u::Activity& e)
+static void on_exec_completion(const simgrid::s4u::Activity& e)
 {
   const auto exec = dynamic_cast<simgrid::kernel::activity::ExecImpl*>(e.get_impl());
   if (exec == nullptr)
index 8cf3644..62062e3 100644 (file)
@@ -49,11 +49,11 @@ bool check_for_cycle(const std::vector<simgrid::s4u::ActivityPtr>& dag)
           // Comms have only one predecessor
           auto pred_pred = *(pred->get_dependencies().begin());
           if (std::none_of(pred_pred->get_successors().begin(), pred_pred->get_successors().end(),
-                           [](const simgrid::s4u::ActivityPtr& a) { return not a->is_marked(); }))
+                           [](const simgrid::s4u::ActivityPtr& act) { return not act->is_marked(); }))
             next.push_back(pred_pred);
         } else {
           if (std::none_of(pred->get_successors().begin(), pred->get_successors().end(),
-                           [](const simgrid::s4u::ActivityPtr& a) { return not a->is_marked(); }))
+                           [](const simgrid::s4u::ActivityPtr& act) { return not act->is_marked(); }))
             next.push_back(pred);
         }
       }