Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
make this loop sonarqube-complient
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 20 Jun 2016 15:46:15 +0000 (17:46 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 20 Jun 2016 15:46:15 +0000 (17:46 +0200)
examples/s4u/actions-comm/s4u_actions-comm.cpp

index cc77351..3601127 100644 (file)
@@ -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 */
   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;
   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);
   }
 }
     MSG_comm_destroy(comm);
   }
 }