From 7aa058f61406a26cf8ff9f1a04bfca254c775c62 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Fri, 3 May 2019 11:48:16 +0200 Subject: [PATCH] Change condition for infinite loops (make sonar believe that function can return). --- examples/s4u/actor-daemon/s4u-actor-daemon.cpp | 2 +- teshsuite/s4u/actor-autorestart/actor-autorestart.cpp | 2 +- teshsuite/s4u/actor/actor.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/s4u/actor-daemon/s4u-actor-daemon.cpp b/examples/s4u/actor-daemon/s4u-actor-daemon.cpp index 54037a634b..4372bd4aa7 100644 --- a/examples/s4u/actor-daemon/s4u-actor-daemon.cpp +++ b/examples/s4u/actor-daemon/s4u-actor-daemon.cpp @@ -21,7 +21,7 @@ static void my_daemon() { simgrid::s4u::Actor::self()->daemonize(); - while (1) { + while (simgrid::s4u::this_actor::get_host()->is_on()) { XBT_INFO("Hello from the infinite loop"); simgrid::s4u::this_actor::sleep_for(3.0); } diff --git a/teshsuite/s4u/actor-autorestart/actor-autorestart.cpp b/teshsuite/s4u/actor-autorestart/actor-autorestart.cpp index cc861427e3..89189a9584 100644 --- a/teshsuite/s4u/actor-autorestart/actor-autorestart.cpp +++ b/teshsuite/s4u/actor-autorestart/actor-autorestart.cpp @@ -17,7 +17,7 @@ static void dummy() static void dummy_daemon() { simgrid::s4u::Actor::self()->daemonize(); - while (1) { + while (simgrid::s4u::this_actor::get_host()->is_on()) { XBT_INFO("Hello from the infinite loop"); simgrid::s4u::this_actor::sleep_for(80.0); } diff --git a/teshsuite/s4u/actor/actor.cpp b/teshsuite/s4u/actor/actor.cpp index 6c70080e6e..01558b2c77 100644 --- a/teshsuite/s4u/actor/actor.cpp +++ b/teshsuite/s4u/actor/actor.cpp @@ -12,7 +12,7 @@ static void worker() simgrid::s4u::this_actor::sleep_for(.5); XBT_INFO("Worker started (PID:%ld, PPID:%ld)", simgrid::s4u::this_actor::get_pid(), simgrid::s4u::this_actor::get_ppid()); - while (1) { + while (simgrid::s4u::this_actor::get_host()->is_on()) { simgrid::s4u::this_actor::yield(); XBT_INFO("Plop i am not suspended"); simgrid::s4u::this_actor::sleep_for(1); -- 2.20.1