Fix issues for clang-analyzer-8
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / readir.cpp
index c2a54c3f213d40f02f48462f1570e5367b40f0e3..be95157da7b1e6b605d946c6cc13ad99f0cd840c 100644 (file)
@@ -809,9 +809,13 @@ void check_ir(const char *mdparin, t_inputrec *ir, t_gromppopts *opts,
         {
             sprintf(err_buf, "nstlog must be non-zero");
             CHECK(ir->nstlog == 0);
-            sprintf(err_buf, "nst-transition-matrix (%d) must be an integer multiple of nstlog (%d)",
-                    expand->nstTij, ir->nstlog);
-            CHECK((expand->nstTij % ir->nstlog) != 0);
+            // Avoid modulus by zero in the case that already triggered an error exit.
+            if (ir->nstlog != 0)
+            {
+                sprintf(err_buf, "nst-transition-matrix (%d) must be an integer multiple of nstlog (%d)",
+                        expand->nstTij, ir->nstlog);
+                CHECK((expand->nstTij % ir->nstlog) != 0);
+            }
         }
     }