From b383052570bf2f171e76fbf038b0f85b63a987df Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 20 Jun 2016 17:46:15 +0200 Subject: [PATCH 1/1] make this loop sonarqube-complient --- examples/s4u/actions-comm/s4u_actions-comm.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/s4u/actions-comm/s4u_actions-comm.cpp b/examples/s4u/actions-comm/s4u_actions-comm.cpp index cc773519aa..360112702f 100644 --- a/examples/s4u/actions-comm/s4u_actions-comm.cpp +++ b/examples/s4u/actions-comm/s4u_actions-comm.cpp @@ -55,10 +55,12 @@ static void asynchronous_cleanup(void) process_globals_t globals = (process_globals_t) MSG_process_get_data(MSG_process_self()); /* Destroy any isend which correspond to completed communications */ - int found; msg_comm_t comm; - while ((found = MSG_comm_testany(globals->isends)) != -1) { - xbt_dynar_remove_at(globals->isends, found, &comm); + while (true) { + int pos_found = MSG_comm_testany(globals->isends); + if (pos_found == -1) /* none remaining */ + break; + xbt_dynar_remove_at(globals->isends, pos_found, &comm); MSG_comm_destroy(comm); } } -- 2.20.1