Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Misc sonar and codefactor.io issues.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Oct 2022 07:38:25 +0000 (09:38 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 7 Oct 2022 09:20:26 +0000 (11:20 +0200)
src/kernel/resource/WifiLinkImpl.cpp
src/kernel/resource/WifiLinkImpl.hpp
src/surf/network_cm02.cpp
teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp

index 52fdbd8..49a2d3e 100644 (file)
@@ -61,10 +61,10 @@ size_t WifiLinkImpl::get_host_count() const
   return host_rates_.size();
 }
 
-double WifiLinkImpl::wifi_link_dynamic_sharing(WifiLinkImpl* link, double capacity, int n)
+double WifiLinkImpl::wifi_link_dynamic_sharing(const WifiLinkImpl& link, double /*capacity*/, int n)
 {
-  double ratio = link->get_max_ratio(n);
-  XBT_DEBUG("New ratio value concurrency %d: %lf of link capacity on link %s", n, ratio, link->get_name().c_str());
+  double ratio = link.get_max_ratio(n);
+  XBT_DEBUG("New ratio value concurrency %d: %lf of link capacity on link %s", n, ratio, link.get_name().c_str());
   return ratio;
 }
 
@@ -82,23 +82,20 @@ void WifiLinkImpl::dec_active_flux()
 
 void WifiLinkImpl::update_bw_comm_start(const kernel::activity::CommImpl& comm)
 {
-  auto* action = static_cast<kernel::resource::NetworkAction*>(comm.surf_action_);
-
-  auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(action);
+  auto const* actionWifi = dynamic_cast<const simgrid::kernel::resource::WifiLinkAction*>(comm.surf_action_);
   if (actionWifi == nullptr)
     return;
 
-  auto* link_src = actionWifi->get_src_link();
-  auto* link_dst = actionWifi->get_dst_link();
-  if (link_src != nullptr) {
+  if (auto* link_src = actionWifi->get_src_link()) {
     link_src->inc_active_flux();
   }
-  if (link_dst != nullptr) {
+  if (auto* link_dst = actionWifi->get_dst_link()) {
     link_dst->inc_active_flux();
   }
 }
 
-void WifiLinkImpl::update_bw_comm_end(simgrid::kernel::resource::NetworkAction& action, simgrid::kernel::resource::Action::State state)
+void WifiLinkImpl::update_bw_comm_end(const simgrid::kernel::resource::NetworkAction& action,
+                                      simgrid::kernel::resource::Action::State /*state*/)
 {
   if (action.get_state() != kernel::resource::Action::State::FINISHED)
     return;
@@ -136,8 +133,9 @@ bool WifiLinkImpl::toggle_callback()
   if (not use_callback_) {
       XBT_DEBUG("Activate throughput reduction mechanism");
     use_callback_ = true;
-    this->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::WIFI,
-      std::bind(&wifi_link_dynamic_sharing, this, std::placeholders::_1, std::placeholders::_2));
+    this->set_sharing_policy(
+        simgrid::s4u::Link::SharingPolicy::WIFI,
+        std::bind(&wifi_link_dynamic_sharing, std::cref(*this), std::placeholders::_1, std::placeholders::_2));
   }
   return use_callback_;
 }
index 223f63e..ff861db 100644 (file)
@@ -56,10 +56,11 @@ public:
   bool toggle_callback();
 
   static void update_bw_comm_start(const kernel::activity::CommImpl&);
-  static void update_bw_comm_end(simgrid::kernel::resource::NetworkAction& action, simgrid::kernel::resource::Action::State state);
+  static void update_bw_comm_end(const simgrid::kernel::resource::NetworkAction& action,
+                                 simgrid::kernel::resource::Action::State state);
   void inc_active_flux();
   void dec_active_flux();
-  static double wifi_link_dynamic_sharing(WifiLinkImpl* link, double capacity, int n);
+  static double wifi_link_dynamic_sharing(const WifiLinkImpl& link, double capacity, int n);
   double get_max_ratio(int) const;
   size_t get_host_count() const;
 };
index 4ec1f66..73e4ba8 100644 (file)
@@ -240,7 +240,6 @@ void NetworkCm02Model::comm_action_expand_constraints(const s4u::Host* src, cons
     else {
       get_maxmin_system()->update_variable_penalty(action->get_variable(), 0);
     }
-
   }
 
   for (auto const* link : route) {
index 9d63d35..e416141 100644 (file)
@@ -16,7 +16,6 @@ void run_ping_test(const std::vector<std::pair<std::string,std::string>>& mboxes
 /* We need a separate actor so that it can sleep after each test */
 static void main_dispatcher()
 {
-
   const std::vector<std::pair<std::string, std::string>> flows = {
     {"Station 1", "Station 2"},
     {"Station 3", "Station 4"},
@@ -50,8 +49,8 @@ static void main_dispatcher()
   auto* l = (simgrid::kernel::resource::WifiLinkImpl*)simgrid::s4u::Link::by_name("AP1")->get_impl();
   l->toggle_callback();
   run_ping_test(flows, 100000);
-
 }
+
 int main(int argc, char** argv)
 {
   simgrid::s4u::Engine engine(&argc, argv);
@@ -65,7 +64,7 @@ int main(int argc, char** argv)
 void run_ping_test(const std::vector<std::pair<std::string,std::string>>& mboxes, int data_size)
 {
   auto* mailbox = simgrid::s4u::Mailbox::by_name("Test");
-  for(auto pair : mboxes) {
+  for (auto const& pair : mboxes) {
     simgrid::s4u::Actor::create("sender", simgrid::s4u::Host::by_name(pair.first.c_str()), [mailbox, pair, data_size]() {
       double start_time          = simgrid::s4u::Engine::get_clock();
       static std::string message = "message";
@@ -80,7 +79,7 @@ void run_ping_test(const std::vector<std::pair<std::string,std::string>>& mboxes
     for(auto i=1; i<=22; i++) {
       l->set_host_rate(simgrid::s4u::Host::by_name("Station "+std::to_string(i)), 0);
     }
-    }
+  }
   simgrid::s4u::this_actor::sleep_for(10);
   XBT_INFO("\n");
 }