From d7621ee830197a4b0f44de326bbfe4397f0e1d6a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 7 Oct 2022 09:38:25 +0200 Subject: [PATCH] Misc sonar and codefactor.io issues. --- src/kernel/resource/WifiLinkImpl.cpp | 24 +++++++++---------- src/kernel/resource/WifiLinkImpl.hpp | 5 ++-- src/surf/network_cm02.cpp | 1 - .../wifi_usage_decay/wifi_usage_decay.cpp | 7 +++--- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/kernel/resource/WifiLinkImpl.cpp b/src/kernel/resource/WifiLinkImpl.cpp index 52fdbd80f6..49a2d3e82a 100644 --- a/src/kernel/resource/WifiLinkImpl.cpp +++ b/src/kernel/resource/WifiLinkImpl.cpp @@ -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(comm.surf_action_); - - auto const* actionWifi = dynamic_cast(action); + auto const* actionWifi = dynamic_cast(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_; } diff --git a/src/kernel/resource/WifiLinkImpl.hpp b/src/kernel/resource/WifiLinkImpl.hpp index 223f63eab1..ff861dbf41 100644 --- a/src/kernel/resource/WifiLinkImpl.hpp +++ b/src/kernel/resource/WifiLinkImpl.hpp @@ -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; }; diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 4ec1f66a62..73e4ba8d9c 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -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) { diff --git a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp index 9d63d35ffd..e416141a0f 100644 --- a/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp +++ b/teshsuite/models/wifi_usage_decay/wifi_usage_decay.cpp @@ -16,7 +16,6 @@ void run_ping_test(const std::vector>& mboxes /* We need a separate actor so that it can sleep after each test */ static void main_dispatcher() { - const std::vector> 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>& 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>& 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"); } -- 2.20.1