From d112bc7736d9855bfa3924d6ecb83c69785866b0 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 3 May 2019 14:10:18 +0200 Subject: [PATCH] [sonar] Assert that pointer is not null. --- src/plugins/host_energy.cpp | 6 ++++-- src/plugins/host_load.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 125a8c8df0..fb960ad4ca 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -503,7 +503,7 @@ void sg_host_energy_plugin_init() simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); if (vm != nullptr) host = vm->get_pm(); - + xbt_assert(host != nullptr); host->extension()->update(); } }); @@ -520,8 +520,10 @@ void sg_host_energy_update_all() simgrid::simix::simcall([]() { std::vector list = simgrid::s4u::Engine::get_instance()->get_all_hosts(); for (auto const& host : list) - if (dynamic_cast(host) == nullptr) // Ignore virtual machines + if (dynamic_cast(host) == nullptr) { // Ignore virtual machines + xbt_assert(host != nullptr); host->extension()->update(); + } }); } diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index ea40824614..19c495f75c 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -210,7 +210,7 @@ void sg_host_load_plugin_init() simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); if (vm != nullptr) host = vm->get_pm(); - + xbt_assert(host != nullptr); host->extension()->add_activity(&activity); host->extension()->update(); // If the system was idle until now, we need to update *before* // this computation starts running so we can keep track of the @@ -226,7 +226,7 @@ void sg_host_load_plugin_init() simgrid::s4u::VirtualMachine* vm = dynamic_cast(host); if (vm != nullptr) host = vm->get_pm(); - + xbt_assert(host != nullptr); host->extension()->update(); } else { // This runs on multiple hosts -- 2.20.1