Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
simplify this example and please sonar
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 19 Nov 2017 19:28:26 +0000 (20:28 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 19 Nov 2017 19:28:26 +0000 (20:28 +0100)
we basically empty the different sets by unref-ing the actions one by
one. a while loop thus seems more adequate

teshsuite/surf/surf_usage/surf_usage.cpp

index 90914d6..57b800a 100644 (file)
@@ -67,40 +67,32 @@ int main(int argc, char **argv)
     XBT_DEBUG("\t CPU actions");
 
     simgrid::surf::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet();
     XBT_DEBUG("\t CPU actions");
 
     simgrid::surf::ActionList* action_list = surf_cpu_model_pm->getFailedActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
-       XBT_INFO("   CPU Failed action");
-       XBT_DEBUG("\t * Failed : %p", action);
-       action->unref();
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
+      XBT_INFO("   CPU Failed action");
+      XBT_DEBUG("\t * Failed : %p", action);
+      action->unref();
     }
 
     action_list = surf_cpu_model_pm->getDoneActionSet();
     }
 
     action_list = surf_cpu_model_pm->getDoneActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::CpuAction*>(&*it);
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
       XBT_INFO("   CPU Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
     }
 
     action_list = surf_network_model->getFailedActionSet();
       XBT_INFO("   CPU Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
     }
 
     action_list = surf_network_model->getFailedActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
-       XBT_INFO("   Network Failed action");
-       XBT_DEBUG("\t * Failed : %p", action);
-       action->unref();
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
+      XBT_INFO("   Network Failed action");
+      XBT_DEBUG("\t * Failed : %p", action);
+      action->unref();
     }
 
     action_list = surf_network_model->getDoneActionSet();
     }
 
     action_list = surf_network_model->getDoneActionSet();
-    for(simgrid::surf::ActionList::iterator it(action_list->begin()), itNext = it, itend(action_list->end()) ;
-        it != itend ; it=itNext) {
-      ++itNext;
-      simgrid::surf::Action *action = static_cast<simgrid::surf::NetworkAction*>(&*it);
+    while (not action_list->empty()) {
+      simgrid::surf::Action* action = &*action_list->begin();
       XBT_INFO("   Network Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();
       XBT_INFO("   Network Done action");
       XBT_DEBUG("\t * Done : %p", action);
       action->unref();