Fix cppcheck 1.64 warnings
[alexxy/gromacs.git] / src / gromacs / gmxpreprocess / solvate.cpp
index ae7ce1187a6735862ac4200e56bec8263757cb9a..5b5d336fc4d9449f24bdff2ae65d3aac2d02d9d2 100644 (file)
@@ -116,8 +116,10 @@ static void sort_molecule(t_atoms **atoms_solvt, rvec *x, rvec *v, real *r)
             moltp = NOTSET;
             for (j = 0; (j < nrmoltypes) && (moltp == NOTSET); j++)
             {
-                if (strcmp(*(atoms->resinfo[atoms->atom[i].resind].name),
-                           moltypes[j].name) == 0)
+                /* cppcheck-suppress nullPointer
+                 * moltypes is guaranteed to be allocated because otherwise
+                 * nrmoltypes is 0. */
+                if (strcmp(*(atoms->resinfo[atoms->atom[i].resind].name), moltypes[j].name) == 0)
                 {
                     moltp = j;
                 }