From: Frederic Suter Date: Sun, 19 Nov 2017 19:28:26 +0000 (+0100) Subject: simplify this example and please sonar X-Git-Tag: v3.18~242^2~9 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/d520bc81a1d0131736343cd414a0227bf5b624ff?ds=sidebyside simplify this example and please sonar we basically empty the different sets by unref-ing the actions one by one. a while loop thus seems more adequate --- diff --git a/teshsuite/surf/surf_usage/surf_usage.cpp b/teshsuite/surf/surf_usage/surf_usage.cpp index 90914d6477..57b800a1c3 100644 --- a/teshsuite/surf/surf_usage/surf_usage.cpp +++ b/teshsuite/surf/surf_usage/surf_usage.cpp @@ -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(); - 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(&*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(); - 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(&*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(); - 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(&*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(); - 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(&*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();