From: Frederic Suter Date: Sun, 5 Nov 2017 21:30:12 +0000 (+0100) Subject: please sonar X-Git-Tag: v3.18~242^2~90 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/849d25bcc8cbb5365daa9e1c3c71fa20a96ecd59 please sonar --- diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index a912fbb416..351269c3b2 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -371,7 +371,8 @@ void smpi_global_destroy() smpi_bench_destroy(); smpi_shared_destroy(); smpi_deployment_cleanup_instances(); - for (int i = 0, count = smpi_process_count(); i < count; i++) { + int count = smpi_process_count(); + for (int i = 0; i < count; i++) { if(process_data[i]->comm_self()!=MPI_COMM_NULL){ simgrid::smpi::Comm::destroy(process_data[i]->comm_self()); } @@ -658,7 +659,8 @@ int smpi_main(const char* executable, int argc, char *argv[]) } } int ret = 0; - for (int i = 0, count = smpi_process_count(); i < count; i++) { + int count = smpi_process_count(); + for (int i = 0; i < count; i++) { if(process_data[i]->return_value()!=0){ ret=process_data[i]->return_value();//return first non 0 value break; diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index d899ed0c98..6f8446aea5 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -360,7 +360,9 @@ double CpuTiModel::nextOccuringEvent(double now) double min_action_duration = -1; /* iterates over modified cpus to update share resources */ - for(CpuTiList::iterator it(modifiedCpu_->begin()), itend(modifiedCpu_->end()) ; it != itend ;) { + CpuTiList::iterator itend(modifiedCpu_->end()); + CpuTiList::iterator it(modifiedCpu_->begin()); + while (it != itend) { CpuTi *ti = &*it; ++it; ti->updateActionsFinishTime(now); @@ -460,8 +462,8 @@ void CpuTi::apply_event(tmgr_trace_event_t event, double value) double date = surf_get_clock(); /* put all action running on cpu to failed */ - for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()); it != itend ; ++it) { - + ActionTiList::iterator itend(actionSet_->end()); + for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) { CpuTiAction *action = &*it; if (action->getState() == Action::State::running || action->getState() == Action::State::ready @@ -493,7 +495,8 @@ void CpuTi::updateActionsFinishTime(double now) /* update remaining amount of actions */ updateRemainingAmount(now); - for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) { + ActionTiList::iterator itend(actionSet_->end()); + for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) { action = &*it; /* action not running, skip it */ if (action->getStateSet() != surf_cpu_model_pm->getRunningActionSet()) @@ -511,7 +514,7 @@ void CpuTi::updateActionsFinishTime(double now) } sumPriority_ = sum_priority; - for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) { + for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) { action = &*it; double min_finish = -1; /* action not running, skip it */ @@ -577,8 +580,8 @@ void CpuTi::updateRemainingAmount(double now) /* compute the integration area */ double area_total = speedIntegratedTrace_->integrate(lastUpdate_, now) * speed_.peak; XBT_DEBUG("Flops total: %f, Last update %f", area_total, lastUpdate_); - - for(ActionTiList::iterator it(actionSet_->begin()), itend(actionSet_->end()) ; it != itend ; ++it) { + ActionTiList::iterator itend(actionSet_->end()); + for (ActionTiList::iterator it(actionSet_->begin()); it != itend; ++it) { CpuTiAction *action = &*it; /* action not running, skip it */ if (action->getStateSet() != model()->getRunningActionSet()) diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index fe92ad9e97..3e9a0c76c8 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -214,12 +214,11 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) void NetworkCm02Model::updateActionsStateFull(double now, double delta) { ActionList *running_actions = getRunningActionSet(); - - for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) - ; it != itend ; it=itNext) { - ++itNext; - + ActionList::iterator it(running_actions->begin()); + ActionList::iterator itend(running_actions->end()); + while (it != itend) { NetworkCm02Action *action = static_cast (&*it); + ++it; XBT_DEBUG("Something happened to action %p", action); double deltap = delta; if (action->latency_ > 0) { diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index e25812ce16..722968594a 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -76,11 +76,11 @@ double StorageN11Model::nextOccuringEvent(double now) void StorageN11Model::updateActionsState(double /*now*/, double delta) { ActionList *actionSet = getRunningActionSet(); - for (ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()); it != itend; it = itNext) { - ++itNext; - + ActionList::iterator it(actionSet->begin()); + ActionList::iterator itend(actionSet->end()); + while (it != itend) { StorageAction *action = static_cast(&*it); - + ++it; double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta); action->updateRemains(current_progress); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 5cad6feeae..2496a4bc81 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -239,7 +239,7 @@ public: void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat); void heapRemove(xbt_heap_t heap); void heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat); - virtual void updateIndexHeap(int i); + void updateIndexHeap(int i); lmm_variable_t getVariable() {return variable_;} void setVariable(lmm_variable_t var) { variable_ = var; } double getLastUpdate() {return lastUpdate_;}