Restrict scope of step and step_rel
authorMark Abraham <mark.j.abraham@gmail.com>
Thu, 19 Aug 2021 05:45:25 +0000 (07:45 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Thu, 19 Aug 2021 09:02:53 +0000 (09:02 +0000)
This prevents use-before-set issues

src/gromacs/mdrun/md.cpp
src/gromacs/mdrun/mimic.cpp
src/gromacs/mdrun/rerun.cpp

index 3b7466c229cc2c2d8ff49f68d5d2ce3e1bb9b9c5..1490fd893c3573e367103f4ca80b943b28f295ce 100644 (file)
@@ -167,7 +167,6 @@ void gmx::LegacySimulator::do_md()
     // will go away eventually.
     const t_inputrec* ir = inputrec;
 
-    int64_t      step, step_rel;
     double       t, t0 = ir->init_t;
     gmx_bool     bGStatEveryStep, bGStat, bCalcVir, bCalcEnerStep, bCalcEner;
     gmx_bool     bNS = FALSE, bNStList, bStopCM, bFirstStep, bInitStep, bLastStep = FALSE;
@@ -802,8 +801,8 @@ void gmx::LegacySimulator::do_md()
     bExchanged       = FALSE;
     bNeedRepartition = FALSE;
 
-    step     = ir->init_step;
-    step_rel = 0;
+    int64_t step     = ir->init_step;
+    int64_t step_rel = 0;
 
     auto stopHandler = stopHandlerBuilder->getStopHandlerMD(
             compat::not_null<SimulationSignal*>(&signals[eglsSTOPCOND]),
index 5c6fa4debb91d0a3499cdb4492aa5c734da67f60..ec45896922dd22979027284079bc81093d39847b 100644 (file)
@@ -143,7 +143,6 @@ using gmx::SimulationSignaller;
 void gmx::LegacySimulator::do_mimic()
 {
     const t_inputrec* ir = inputrec;
-    int64_t           step, step_rel;
     double            t;
     bool              isLastStep               = false;
     bool              doFreeEnergyPerturbation = false;
@@ -415,8 +414,8 @@ void gmx::LegacySimulator::do_mimic()
                     "MiMiC does not report kinetic energy, total energy, temperature, virial and "
                     "pressure.");
 
-    step     = ir->init_step;
-    step_rel = 0;
+    int64_t step     = ir->init_step;
+    int64_t step_rel = 0;
 
     auto stopHandler = stopHandlerBuilder->getStopHandlerMD(
             compat::not_null<SimulationSignal*>(&signals[eglsSTOPCOND]),
index 407c0190f6daf49aeacbfee850c1ac53e22d805c..cd648a504e98e7b9723bc6f5a010d7dc6c25a250 100644 (file)
@@ -174,7 +174,6 @@ void gmx::LegacySimulator::do_rerun()
     // t_inputrec is being replaced by IMdpOptionsProvider, so this
     // will go away eventually.
     const t_inputrec* ir = inputrec;
-    int64_t           step, step_rel;
     double            t;
     bool              isLastStep               = false;
     bool              doFreeEnergyPerturbation = false;
@@ -511,8 +510,8 @@ void gmx::LegacySimulator::do_rerun()
         calc_shifts(rerun_fr.box, fr->shift_vec);
     }
 
-    step     = ir->init_step;
-    step_rel = 0;
+    int64_t step     = ir->init_step;
+    int64_t step_rel = 0;
 
     auto stopHandler = stopHandlerBuilder->getStopHandlerMD(
             compat::not_null<SimulationSignal*>(&signals[eglsSTOPCOND]),