From d79578eb4d1e1336da580baa30edbbee18121e7f Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Fri, 16 Jul 2021 11:11:31 +0200 Subject: [PATCH] The next day sonar commit --- .../exec-cpu-nonlinear/s4u-exec-cpu-nonlinear.cpp | 2 +- examples/cpp/io-degradation/s4u-io-degradation.cpp | 13 ++++--------- src/kernel/resource/DiskImpl.cpp | 10 ++++------ src/surf/SplitDuplexLinkImpl_test.cpp | 3 ++- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/examples/cpp/exec-cpu-nonlinear/s4u-exec-cpu-nonlinear.cpp b/examples/cpp/exec-cpu-nonlinear/s4u-exec-cpu-nonlinear.cpp index 9331ef981c..8c5280d21f 100644 --- a/examples/cpp/exec-cpu-nonlinear/s4u-exec-cpu-nonlinear.cpp +++ b/examples/cpp/exec-cpu-nonlinear/s4u-exec-cpu-nonlinear.cpp @@ -27,7 +27,7 @@ static void runner() tasks.emplace_back(sg4::this_actor::exec_async(computation_amount)); } XBT_INFO("Waiting for all tasks to be done!"); - for (auto& task : tasks) + for (const auto& task : tasks) task->wait(); XBT_INFO("Finished executing. Goodbye now!"); diff --git a/examples/cpp/io-degradation/s4u-io-degradation.cpp b/examples/cpp/io-degradation/s4u-io-degradation.cpp index 834872a748..384b709a70 100644 --- a/examples/cpp/io-degradation/s4u-io-degradation.cpp +++ b/examples/cpp/io-degradation/s4u-io-degradation.cpp @@ -21,7 +21,7 @@ namespace sg4 = simgrid::s4u; XBT_LOG_NEW_DEFAULT_CATEGORY(disk_test, "Messages specific for this simulation"); /** @brief Calculates the bandwidth for disk doing async operations */ -static void estimate_bw(sg4::Disk* disk, int n_flows, bool read) +static void estimate_bw(const sg4::Disk* disk, int n_flows, bool read) { unsigned long long size = 100000; double cur_time = sg4::Engine::get_clock(); @@ -36,11 +36,11 @@ static void estimate_bw(sg4::Disk* disk, int n_flows, bool read) activities.push_back(act); } - for (auto& act : activities) + for (const auto& act : activities) act->wait(); double elapsed_time = sg4::Engine::get_clock() - cur_time; - double estimated_bw = size * n_flows / elapsed_time; + double estimated_bw = static_cast(size * n_flows) / elapsed_time; XBT_INFO("Disk: %s, concurrent %s: %d, estimated bandwidth: %lf", disk->get_cname(), read ? "read" : "write", n_flows, estimated_bw); } @@ -93,8 +93,6 @@ static double ssd_dynamic_sharing(const sg4::Disk* /*disk*/, const std::string& if (data.find(n) != data.end()) capacity = data.at(n); - // XBT_INFO("Disk %s, %s operation between %d flows, capacity %lf", disk->get_cname(), op.c_str(), n, capacity); - return capacity; } @@ -109,10 +107,7 @@ static double ssd_dynamic_sharing(const sg4::Disk* /*disk*/, const std::string& */ static double sata_dynamic_sharing(const sg4::Disk* /*disk*/, double capacity, int n) { - capacity = 68.3 - 1.7 * n; - // XBT_INFO("Disk %s, read operation between %d flows, capacity %lf", disk->get_cname(), n, capacity); - - return capacity; + return 68.3 - 1.7 * n; } /** @brief Creates an SSD disk, setting the appropriate callback for non-linear resource sharing */ diff --git a/src/kernel/resource/DiskImpl.cpp b/src/kernel/resource/DiskImpl.cpp index acd3ff3d0f..dc0944946f 100644 --- a/src/kernel/resource/DiskImpl.cpp +++ b/src/kernel/resource/DiskImpl.cpp @@ -124,12 +124,10 @@ void DiskImpl::seal() constexpr kernel::lmm::Constraint::SharingPolicy to_maxmin_policy(s4u::Disk::SharingPolicy policy) { - switch (policy) { - case s4u::Disk::SharingPolicy::NONLINEAR: - return kernel::lmm::Constraint::SharingPolicy::NONLINEAR; - default: - return kernel::lmm::Constraint::SharingPolicy::SHARED; - } + kernel::lmm::Constraint::SharingPolicy lmm_policy = kernel::lmm::Constraint::SharingPolicy::SHARED; + if (policy == s4u::Disk::SharingPolicy::NONLINEAR) + lmm_policy = kernel::lmm::Constraint::SharingPolicy::NONLINEAR; + return lmm_policy; } void DiskImpl::set_sharing_policy(s4u::Disk::Operation op, s4u::Disk::SharingPolicy policy, diff --git a/src/surf/SplitDuplexLinkImpl_test.cpp b/src/surf/SplitDuplexLinkImpl_test.cpp index 5bf5ef8d1b..8a2a928a91 100644 --- a/src/surf/SplitDuplexLinkImpl_test.cpp +++ b/src/surf/SplitDuplexLinkImpl_test.cpp @@ -90,7 +90,8 @@ TEST_CASE("SplitDuplexLink: sets", "") SECTION("sharing_policy: nonlinear") { - link->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::NONLINEAR, [](double c, int n) -> double { return c; }); + link->set_sharing_policy(simgrid::s4u::Link::SharingPolicy::NONLINEAR, + [](double c, int /*n*/) -> double { return c; }); REQUIRE(link_up->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::NONLINEAR); REQUIRE(link_down->get_sharing_policy() == simgrid::s4u::Link::SharingPolicy::NONLINEAR); } -- 2.20.1