Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 5 Nov 2017 21:30:12 +0000 (22:30 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Sun, 5 Nov 2017 21:30:12 +0000 (22:30 +0100)
src/smpi/internals/smpi_global.cpp
src/surf/cpu_ti.cpp
src/surf/network_cm02.cpp
src/surf/storage_n11.cpp
src/surf/surf_interface.hpp

index a912fbb..351269c 100644 (file)
@@ -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;
index d899ed0..6f8446a 100644 (file)
@@ -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())
index fe92ad9..3e9a0c7 100644 (file)
@@ -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<NetworkCm02Action*> (&*it);
+    ++it;
     XBT_DEBUG("Something happened to action %p", action);
       double deltap = delta;
       if (action->latency_ > 0) {
index e25812c..7229685 100644 (file)
@@ -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<StorageAction*>(&*it);
-
+    ++it;
     double current_progress = lrint(lmm_variable_getvalue(action->getVariable()) * delta);
 
     action->updateRemains(current_progress);
index 5cad6fe..2496a4b 100644 (file)
@@ -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_;}