From: Arnaud Giersch Date: Fri, 3 May 2019 12:10:18 +0000 (+0200) Subject: [sonar] Assert that pointer is not null. X-Git-Tag: v3.22.2~7 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d112bc7736d9855bfa3924d6ecb83c69785866b0 [sonar] Assert that pointer is not null. --- 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