Fix issues for clang-analyzer-8
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / gen_vsite.cpp
index 38537e1a4cafc8ef47501c0a950c00a52d5fe848..dacc3175527870feed2123755f38d5d9bd0d3ff5 100644 (file)
@@ -1558,7 +1558,7 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, PreprocessingAtom
                const char *ffdir)
 {
 #define MAXATOMSPERRESIDUE 16
-    int                        k, m, i0, ni0, whatres, resind, add_shift, nvsite, nadd;
+    int                        k, m, i0, ni0, whatres, add_shift, nvsite, nadd;
     int                        ai, aj, ak, al;
     int                        nrfound = 0, needed, nrbonds, nrHatoms, Heavy, nrheavies, tpM, tpHeavy;
     int                        Hatoms[4], heavies[4];
@@ -1570,7 +1570,6 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, PreprocessingAtom
     int                       *o2n, *newvsite_type, *newcgnr, ats[MAXATOMSPERRESIDUE];
     t_atom                    *newatom;
     char                    ***newatomname;
-    char                      *resnm = nullptr;
     int                        cmplength;
     bool                       isN, planarN, bFound;
 
@@ -1661,14 +1660,14 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, PreprocessingAtom
 
     /* generate vsite constructions */
     /* loop over all atoms */
-    resind = -1;
+    int resind = -1;
     for (int i = 0; (i < at->nr); i++)
     {
         if (at->atom[i].resind != resind)
         {
             resind = at->atom[i].resind;
-            resnm  = *(at->resinfo[resind].name);
         }
+        const char *resnm = *(at->resinfo[resind].name);
         /* first check for aromatics to virtualize */
         /* don't waste our effort on DNA, water etc. */
         /* Only do the vsite aromatic stuff when we reach the
@@ -2028,11 +2027,10 @@ void do_vsites(gmx::ArrayRef<const PreprocessResidue> rtpFFDB, PreprocessingAtom
             }
             if (bWARNING)
             {
-                fprintf(stderr,
-                        "Warning: cannot convert atom %d %s (bound to a heavy atom "
-                        "%s with \n"
-                        "         %d bonds and %d bound hydrogens atoms) to virtual site\n",
-                        i+1, *(at->atomname[i]), tpname, nrbonds, nrHatoms);
+                gmx_fatal(FARGS, "Cannot convert atom %d %s (bound to a heavy atom "
+                          "%s with \n"
+                          "         %d bonds and %d bound hydrogens atoms) to virtual site\n",
+                          i+1, *(at->atomname[i]), tpname, nrbonds, nrHatoms);
             }
             if (bAddVsiteParam)
             {