Fix issues to update cppcheck support to 1.72
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 9 Feb 2016 12:51:59 +0000 (13:51 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 10 Feb 2016 10:53:02 +0000 (11:53 +0100)
Bumped requirement for cppcheck in releng.

Changed the output template to make it easier to find cppcheck's
name for the error when a suppression needs to be added.

Bugs found in gmx_lapack (checked by comparing with Fortran version).

Simplified some checkpoint-reading code, since reading always does the
allocation.

Removed some unused OpenCL debug code.

Removed some suppressions no longer needed.

Change-Id: I882ea877bd489ca253b5a7f06becb7e43bb6a3d0

46 files changed:
admin/builds/cppcheck.py
src/external/thread_mpi/include/thread_mpi/system_error.h
src/gromacs/commandline/cmdlineparser.h
src/gromacs/commandline/cmdlineprogramcontext.cpp
src/gromacs/correlationfunctions/expfit.cpp
src/gromacs/domdec/domdec.cpp
src/gromacs/ewald/pme-pp.cpp
src/gromacs/fft/fft5d.cpp
src/gromacs/fileio/checkpoint.cpp
src/gromacs/fileio/espio.cpp
src/gromacs/fileio/libxdrf.cpp
src/gromacs/fileio/pdbio.cpp
src/gromacs/fileio/tngio_for_tools.cpp
src/gromacs/gmxana/gmx_chi.cpp
src/gromacs/gmxana/gmx_densmap.cpp
src/gromacs/gmxana/gmx_disre.cpp
src/gromacs/gmxana/gmx_eneconv.cpp
src/gromacs/gmxana/gmx_energy.cpp
src/gromacs/gmxana/gmx_hbond.cpp
src/gromacs/gmxana/gmx_nmeig.cpp
src/gromacs/gmxana/gmx_pme_error.cpp
src/gromacs/gmxana/gmx_sham.cpp
src/gromacs/gmxana/gmx_xpm2ps.cpp
src/gromacs/gmxlib/network.cpp
src/gromacs/gmxpreprocess/topio.cpp
src/gromacs/gmxpreprocess/toppush.cpp
src/gromacs/linearalgebra/gmx_arpack.cpp
src/gromacs/linearalgebra/gmx_lapack/dlasv2.cpp
src/gromacs/linearalgebra/gmx_lapack/slasv2.cpp
src/gromacs/mdlib/mdoutf.cpp
src/gromacs/mdlib/minimize.cpp
src/gromacs/mdlib/nbnxn_ocl/nbnxn_ocl.cpp
src/gromacs/mdlib/nbnxn_search.cpp
src/gromacs/options/optionstoragetemplate.h
src/gromacs/selection/parsetree.cpp
src/gromacs/selection/scanner_internal.cpp
src/gromacs/selection/sm_insolidangle.cpp
src/gromacs/topology/atoms.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/mtop_util.cpp
src/gromacs/topology/residuetypes.cpp
src/gromacs/trajectoryanalysis/modules/angle.cpp
src/gromacs/trajectoryanalysis/modules/freevolume.cpp
src/gromacs/trajectoryanalysis/runnercommon.cpp
src/testutils/tests/interactivetest.cpp
tests/CppCheck.cmake

index 0cef6ec39cd3e84654e55e182e69ce0e83be1424..85711e98b1e86b6db5eabda9ffe616a4629daf10 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2015, by the GROMACS development team, led by
+# Copyright (c) 2015,2016, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -36,7 +36,7 @@ def do_build(context):
     # TODO: Make the XMLs go directly to the desired folder.
     # xml_dir = context.workspace.get_log_dir(category='cppcheck')
     cmake_opts = {
-            'CPPCHECK_EXECUTABLE': context.env.get_cppcheck_command(version='1.67'),
+            'CPPCHECK_EXECUTABLE': context.env.get_cppcheck_command(version='1.72'),
             'CPPCHECK_XML_OUTPUT': 'ON',
             'GMX_SIMD': 'Reference'
         }
index 80c94e2089893fdfd7c5db7ce3da283e53a1221e..c1d046ecf7751e330e19944741b2be58aa0e76b5 100644 (file)
@@ -64,7 +64,7 @@ class system_error : public std::runtime_error
         //system_error(error_code ec, const std::string& what_arg);
         //system_error(error_code ec, const char* what_arg);
         /*! \brief Constuctor that takes an system error number */
-        system_error(error_code ec);
+        explicit system_error(error_code ec);
 
         /*! \brief Returns the error code */
         const error_code &code() const
index e599ed0ab0ce70230d49b2252c44f36267e958d3..7f90b1a2dc6475415e3871be89b46d0f49568323 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -77,7 +77,7 @@ class CommandLineParser
          * \param[in] options  Options object whose options should be set.
          * \throws  std::bad_alloc if out of memory.
          */
-        CommandLineParser(Options *options);
+        explicit CommandLineParser(Options *options);
         ~CommandLineParser();
 
         /*! \brief
index 92699e4d8ac7f4967727a39c4105285760c2bea1..7d61b0c0715bfb4a769ecbfc5037e47046d65985 100644 (file)
@@ -328,9 +328,8 @@ CommandLineProgramContext::Impl::Impl()
 
 CommandLineProgramContext::Impl::Impl(int argc, const char *const argv[],
                                       ExecutableEnvironmentPointer env)
-    : executableEnv_(std::move(env)), bSourceLayout_(false)
+    : executableEnv_(std::move(env)), invokedName_(argc != 0 ? argv[0] : ""), bSourceLayout_(false)
 {
-    invokedName_ = (argc != 0 ? argv[0] : "");
     programName_ = Path::getFilename(invokedName_);
     programName_ = stripSuffixIfPresent(programName_, ".exe");
 
index 26e56f3fe9be04d56f9690470cede92d85965706..f75133ae046b7cb1ad847dd397c426b1daf69c68 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -824,7 +824,7 @@ real do_lmfit(int ndata, real c1[], real sig[], real dt, real *x0,
                 {
                     real ttt = x0 ? x0[j] : dt*j;
                     fprintf(fp, "%10.5e  %10.5e  %10.5e\n",
-                            x[j], y[j], lmcurves[eFitFn](ttt, fitparms));
+                            x[j], y[j], (lmcurves[eFitFn])(ttt, fitparms));
                 }
                 xvgrclose(fp);
             }
index 87a0340860276f6e50759a4900e18b5eda04e87d..e96e408cc3e003a072866ddf2dcd024ac8b62836 100644 (file)
@@ -3603,15 +3603,12 @@ static void distribute_cg(FILE *fplog,
 
     ma = dd->ma;
 
-    if (tmp_ind == NULL)
+    snew(tmp_nalloc, dd->nnodes);
+    snew(tmp_ind, dd->nnodes);
+    for (i = 0; i < dd->nnodes; i++)
     {
-        snew(tmp_nalloc, dd->nnodes);
-        snew(tmp_ind, dd->nnodes);
-        for (i = 0; i < dd->nnodes; i++)
-        {
-            tmp_nalloc[i] = over_alloc_large(cgs->nr/dd->nnodes+1);
-            snew(tmp_ind[i], tmp_nalloc[i]);
-        }
+        tmp_nalloc[i] = over_alloc_large(cgs->nr/dd->nnodes+1);
+        snew(tmp_ind[i], tmp_nalloc[i]);
     }
 
     /* Clear the count */
index 4fbb3b5814984bc5330ec3e5f51013d31d99d730..20181bf75a56b3158309b59dba4c77683c646dab 100644 (file)
@@ -226,10 +226,10 @@ static void gmx_pme_send_coeffs_coords(t_commrec *cr, int flags,
     {
         fprintf(debug, "PP rank %d sending to PME rank %d: %d%s%s%s%s\n",
                 cr->sim_nodeid, dd->pme_nodeid, n,
-                flags & PP_PME_CHARGE ? " charges" : "",
-                flags & PP_PME_SQRTC6 ? " sqrtC6" : "",
-                flags & PP_PME_SIGMA  ? " sigma" : "",
-                flags & PP_PME_COORD  ? " coordinates" : "");
+                (flags & PP_PME_CHARGE) ? " charges" : "",
+                (flags & PP_PME_SQRTC6) ? " sqrtC6" : "",
+                (flags & PP_PME_SIGMA)  ? " sigma" : "",
+                (flags & PP_PME_COORD)  ? " coordinates" : "");
     }
 
 #ifdef GMX_PME_DELAYED_WAIT
index 7dba223d9819aa6826f4df40a89c61a241ccbb7d..471f57c25b43e66eff7b77cd6f0c7e94a8d4bfc0 100644 (file)
@@ -947,7 +947,7 @@ static void print_localdata(const t_complex* lin, const char* txt, int s, fft5d_
     int  xs[3], xl[3], xc[3], NG[3];
     int  ll = (plan->flags&FFT5D_REALCOMPLEX) ? 1 : 2;
     compute_offsets(plan, xs, xl, xc, NG, s);
-    fprintf(debug, txt, coor[0], coor[1], s);
+    fprintf(debug, txt, coor[0], coor[1]);
     /*printf("xs: %d %d %d, xl: %d %d %d\n",xs[0],xs[1],xs[2],xl[0],xl[1],xl[2]);*/
     for (z = 0; z < xl[2]; z++)
     {
index 936b7f9dca11bfb4eb09cda545d9b0da4a388e88..f748f5cdd87dea46d13b9ee9d3c257d0aee53489 100644 (file)
@@ -314,16 +314,13 @@ static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags,
                              int nval, int *nptr, real **v,
                              FILE *list, int erealtype)
 {
-    bool_t  res = 0;
-#if !GMX_DOUBLE
-    int     dtc = xdr_datatype_float;
-#else
-    int     dtc = xdr_datatype_double;
-#endif
-    real   *vp, *va = NULL;
-    float  *vf;
-    double *vd;
-    int     nf, dt, i;
+    bool_t     res       = 0;
+    const bool useDouble = GMX_DOUBLE;
+    int        dtc       = useDouble ? xdr_datatype_double : xdr_datatype_float;
+    real      *vp, *va = NULL;
+    float     *vf;
+    double    *vd;
+    int        nf, dt, i;
 
     if (list == NULL)
     {
@@ -386,8 +383,9 @@ static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags,
     }
     if (dt == xdr_datatype_float)
     {
-        if (dtc == xdr_datatype_float)
+        if (!useDouble)
         {
+            // This branch is not reached unless vp is already float *.
             vf = reinterpret_cast<float *>(vp);
         }
         else
@@ -400,7 +398,7 @@ static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags,
         {
             return -1;
         }
-        if (dtc != xdr_datatype_float)
+        if (useDouble)
         {
             for (i = 0; i < nf; i++)
             {
@@ -411,11 +409,10 @@ static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags,
     }
     else
     {
-        if (dtc == xdr_datatype_double)
+        if (useDouble)
         {
-            /* cppcheck-suppress invalidPointerCast
-             * Only executed if real is anyhow double */
-            vd = (double *)vp;
+            // This branch is not reached unless vp is already double *.
+            vd = reinterpret_cast<double *>(vp);
         }
         else
         {
@@ -427,7 +424,7 @@ static int do_cpte_reals_low(XDR *xd, int cptp, int ecpt, int sflags,
         {
             return -1;
         }
-        if (dtc != xdr_datatype_double)
+        if (!useDouble)
         {
             for (i = 0; i < nf; i++)
             {
@@ -2357,13 +2354,21 @@ static void read_checkpoint_data(t_fileio *fp, int *simulation_part,
     }
 
     ret = do_cpt_files(gmx_fio_getxdr(fp), TRUE,
-                       outputfiles != NULL ? outputfiles : &files_loc,
-                       outputfiles != NULL ? nfiles : &nfiles_loc,
+                       &files_loc,
+                       &nfiles_loc,
                        NULL, file_version);
-    if (files_loc != NULL)
+    if (outputfiles != nullptr)
+    {
+        *outputfiles = files_loc;
+    }
+    else
     {
         sfree(files_loc);
     }
+    if (nfiles != nullptr)
+    {
+        *nfiles = nfiles_loc;
+    }
 
     if (ret)
     {
index babf898bf774995e12d35ca864cff19c6dcd2d2e..c2886b4eb6d7cb4b786101144ac045f2a3e14825 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 2005, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -292,7 +292,7 @@ void gmx_espresso_read_conf(const char *infile,
                         }
                     }
                     /* Generate an atom name from the particle type */
-                    sprintf(buf, "T%d", atoms->atom[i].type);
+                    sprintf(buf, "T%u", atoms->atom[i].type);
                     atoms->atomname[i] = put_symtab(&top->symtab, buf);
                     if (bMol)
                     {
@@ -449,7 +449,7 @@ void write_espresso_conf_indexed(FILE *out, const char *title,
         {
             j = i;
         }
-        fprintf(out, "\t{%d %f %f %f %d %g",
+        fprintf(out, "\t{%d %f %f %f %u %g",
                 j, x[j][XX], x[j][YY], x[j][ZZ],
                 atoms->atom[j].type, atoms->atom[j].q);
         if (v)
index 8f6aecf9b89301392b8dccbdedc0bc21b1e43c48..ceabe761ecb64e41b7aee6cb144a68d091dc71d9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -1640,7 +1640,7 @@ xdr_xtc_get_last_frame_number(FILE *fp, XDR *xdrs, int natoms, gmx_bool * bOK)
     }
 
     frame = xtc_get_current_frame_number(fp, xdrs, natoms, bOK);
-    if (!bOK)
+    if (!*bOK)
     {
         return -1;
     }
index f2fc237e6c8215f5b2089c63e0e5fa0c21148f6d..e13ad287dc54a3de49d1b2e2c8db93f2739167f1 100644 (file)
@@ -59,6 +59,7 @@
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/futil.h"
 #include "gromacs/utility/smalloc.h"
+#include "gromacs/utility/snprintf.h"
 
 typedef struct {
     int ai, aj;
@@ -522,7 +523,7 @@ void get_pdb_atomnumber(t_atoms *atoms, gmx_atomprop_t aps)
         std::strcpy(anm_copy, atoms->pdbinfo[i].atomnm);
         bool atomNumberSet = false;
         len        = strlen(anm);
-        if ((anm[0] != ' ') && ((len <= 2) || ((len > 2) && !std::isdigit(anm[2]))))
+        if ((anm[0] != ' ') && ((len <= 2) || !std::isdigit(anm[2])))
         {
             anm_copy[2] = nc;
             if (gmx_atomprop_query(aps, epropElement, "???", anm_copy, &eval))
@@ -1088,7 +1089,7 @@ gmx_fprintf_pdb_atomline(FILE *            fp,
         {
             start_name_in_col13 = (std::strlen(atom_name) >= 4);
         }
-        sprintf(tmp_atomname, start_name_in_col13 ? "" : " ");
+        snprintf(tmp_atomname, sizeof(tmp_atomname), start_name_in_col13 ? "" : " ");
         std::strncat(tmp_atomname, atom_name, 4);
         tmp_atomname[5] = '\0';
     }
index 4f1c49bdd8f6ac2474046ac5053e8da57e3e012c..5ef57a9e9581cb43a7c6e547e4dde78e61a9ce3f 100644 (file)
@@ -226,12 +226,13 @@ convert_array_to_real_array(void       *from,
                             const int   nValues,
                             const char  datatype)
 {
-    int i, j;
+    int        i, j;
 
+    const bool useDouble = GMX_DOUBLE;
     switch (datatype)
     {
         case TNG_FLOAT_DATA:
-            if (sizeof(real) == sizeof(float))
+            if (!useDouble)
             {
                 if (fact == 1)
                 {
index af4fce1bb08a8a5afef1d2481a41ee2b7bb27b35..2ff98fe4457416cb917e5b5cc48f020f818c91af 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -562,7 +562,7 @@ static void histogramming(FILE *log, int nbin, gmx_residuetype_t *rt,
                         bBfac  = bBfac  && (atoms->pdbinfo[index[n]].bfac <= bfac_max);
                         bOccup = bOccup && (atoms->pdbinfo[index[n]].occup == 1);
                     }
-                    if (bOccup && ((bfac_max <= 0) || ((bfac_max > 0) && bBfac)))
+                    if (bOccup && ((bfac_max <= 0) || bBfac))
                     {
                         hindex = static_cast<int>(((dih[j][0]+M_PI)*nbin)/(2*M_PI));
                         range_check(hindex, 0, nbin);
index 6d376c47fe9064e30ad854804cbc79cbbf548f35..45d09ee9c298ad7f8b9cea56490c75f93cafb624 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -252,9 +252,7 @@ int gmx_densmap(int argc, char *argv[])
     {
         n1      = static_cast<int>(2*amax/bin + 0.5);
         nradial = static_cast<int>(rmax/bin + 0.5);
-        /* cppcheck-suppress zerodiv fixed in 1.68-dev */
         invspa  = n1/(2*amax);
-        /* cppcheck-suppress zerodiv fixed in 1.68-dev */
         invspz  = nradial/rmax;
         if (bMirror)
         {
index 62588faa99329858a9ef72708876d70be6a9cf68..50153782c47fb87b4007d6f1d81cc32cca334940 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -313,7 +313,7 @@ static void dump_dump(FILE *log, int ndr, t_dr_stats drs[])
             nrestr    = 0;
             for (i = 0; (i < ndr); i++)
             {
-                if (!bCore || (bCore && drs[i].bCore))
+                if (!bCore || drs[i].bCore)
                 {
                     switch (kkk)
                     {
index 0f8dcdba692c7974686819945166677be94329c0..5c27bcb1c7b38cd47880e7d83ea925240157594f 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -595,8 +595,8 @@ int gmx_eneconv(int argc, char *argv[])
             fro->step = lastfilestep + fr->step - startstep_file;
             fro->t    = tadjust  + fr->t;
 
-            bWrite = ((begin < 0 || (begin >= 0 && (fro->t >= begin-GMX_REAL_EPS))) &&
-                      (end  < 0 || (end  >= 0 && (fro->t <= end  +GMX_REAL_EPS))) &&
+            bWrite = ((begin < 0 || (fro->t >= begin-GMX_REAL_EPS)) &&
+                      (end  < 0  || (fro->t <= end  +GMX_REAL_EPS)) &&
                       (fro->t <= settime[f+1]+0.5*timestep));
 
             if (debug)
index 07ae1e55d95dd47a6594d38ccc0a545786639468..9d63edb8551e11fd932c0f735b2befac9caa881a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -1610,6 +1610,7 @@ static void do_dhdl(t_enxframe *fr, t_inputrec *ir, FILE **fp_dhdl,
     double      *native_lambda_vec = NULL;
     const char **lambda_components = NULL;
     int          n_lambda_vec      = 0;
+    bool         firstPass         = true;
 
     /* now count the blocks & handle the global dh data */
     for (i = 0; i < fr->nblock; i++)
@@ -1639,9 +1640,12 @@ static void do_dhdl(t_enxframe *fr, t_inputrec *ir, FILE **fp_dhdl,
             start_lambda    = fr->block[i].sub[0].dval[3];
             if (fr->block[i].nsub > 1)
             {
-                if (n_lambda_vec == 0)
+                if (firstPass)
                 {
                     n_lambda_vec = fr->block[i].sub[1].ival[1];
+                    snew(lambda_components, n_lambda_vec);
+                    snew(native_lambda_vec, n_lambda_vec);
+                    firstPass = false;
                 }
                 else
                 {
@@ -1651,14 +1655,6 @@ static void do_dhdl(t_enxframe *fr, t_inputrec *ir, FILE **fp_dhdl,
                                   "Unexpected change of basis set in lambda");
                     }
                 }
-                if (lambda_components == NULL)
-                {
-                    snew(lambda_components, n_lambda_vec);
-                }
-                if (native_lambda_vec == NULL)
-                {
-                    snew(native_lambda_vec, n_lambda_vec);
-                }
                 for (j = 0; j < n_lambda_vec; j++)
                 {
                     native_lambda_vec[j] = fr->block[i].sub[0].dval[5+j];
index 86d5ee2d9105b224f4e0bfba1481b8eaf88c77ff..4c283352ea4b1a1ff6c45722cc8af86959ad471d 100644 (file)
@@ -1321,7 +1321,7 @@ static int is_hbond(t_hbdata *hb, int grpd, int grpa, int d, int a,
             rha2 = iprod(r_ha, r_ha);
         }
 
-        if (bDA || (!bDA && (rha2 <= rc2)))
+        if (bDA || (rha2 <= rc2))
         {
             rvec_sub(x[d], x[hh], r_dh);
             if (bBox)
@@ -1344,7 +1344,7 @@ static int is_hbond(t_hbdata *hb, int grpd, int grpa, int d, int a,
             }
         }
     }
-    if (bDA || (!bDA && HAinrange))
+    if (bDA || HAinrange)
     {
         return hbDist;
     }
@@ -1443,7 +1443,7 @@ static void merge_hb(t_hbdata *hb, gmx_bool bTwo, gmx_bool bContact)
             ia = hb->a.acc[j];
             jj = hb->d.dptr[ia];
             if ((id != ia) && (ii != NOTSET) && (jj != NOTSET) &&
-                (!bTwo || (bTwo && (hb->d.grp[i] != hb->a.grp[j]))))
+                (!bTwo || (hb->d.grp[i] != hb->a.grp[j])))
             {
                 hb0 = hb->hbmap[i][j];
                 hb1 = hb->hbmap[jj][ii];
index 2f2668559d3bb1d982a1f78454d2a79313b59fb5..6483f13a78c42b46d1e4b7a338ed2fd21e0b7ce0 100644 (file)
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cassert>
 #include <cmath>
 #include <cstring>
 
@@ -443,6 +444,7 @@ int gmx_nmeig(int argc, char *argv[])
     }
     else
     {
+        assert(sparse_hessian);
         /* Sparse memory storage, allocate memory for eigenvectors */
         snew(eigenvectors, ncol*end);
         nma_sparse_hessian(sparse_hessian, bM, &top, atom_index, end, eigenvalues, eigenvectors);
index 4a9a4bff8440dceafbd666044b56185daa8ea45c..5208e8b562f6b361ccc979f90716dbed06e2a47d 100644 (file)
@@ -1144,13 +1144,19 @@ int gmx_pme_error(int argc, char *argv[])
     create_info(&info);
     info.fourier_sp[0] = fs;
 
-    /* Read in the tpr file and open logfile for reading */
     if (MASTER(cr))
     {
+        /* Read in the tpr file */
         snew(ir, 1);
         read_tpr_file(opt2fn("-s", NFILE, fnm), &info, &state, &mtop, ir, user_beta, fracself);
-
+        /* Open logfile for reading */
         fp = fopen(opt2fn("-o", NFILE, fnm), "w");
+
+        /* Determine the volume of the simulation box */
+        info.volume = det(state.box);
+        calc_recipbox(state.box, info.recipbox);
+        info.natoms = mtop.natoms;
+        info.bTUNE  = bTUNE;
     }
 
     /* Check consistency if the user provided fourierspacing */
@@ -1170,15 +1176,6 @@ int gmx_pme_error(int argc, char *argv[])
 
     /* Estimate (S)PME force error */
 
-    /* Determine the volume of the simulation box */
-    if (MASTER(cr))
-    {
-        info.volume = det(state.box);
-        calc_recipbox(state.box, info.recipbox);
-        info.natoms = mtop.natoms;
-        info.bTUNE  = bTUNE;
-    }
-
     if (PAR(cr))
     {
         bcast_info(&info, cr);
index 6ba08278d0b70fac567f4a94d0fb5d42ab63b46e..dbd3838482d102b95669d498610979781405eb51 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cassert>
 #include <cmath>
 #include <cstdlib>
 #include <cstring>
@@ -492,6 +493,7 @@ static void do_sham(const char *fn, const char *ndx,
     snew(bE, n);
     if (bGE || nenerT == 2)
     {
+        assert(enerT);
         Emin = 1e8;
         for (j = 0; (j < n); j++)
         {
index a1f5afb186543d8203df76bfb98634f51a2554b9..4eb173d1d7e7ccaa994bfbec090ccdd249a92424 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cassert>
 #include <cmath>
 #include <cstdio>
 #include <cstdlib>
@@ -594,9 +595,9 @@ static void box_dim(int nmat, t_matrix mat[], t_matrix *mat2, t_psrec *psr,
             dhh += psr->X.fontsize+2*DDD;
         }
         if ( /* fool emacs auto-indent */
-            (elegend == elBoth && (mat[0].legend[0] || mat2[0].legend[0])) ||
+            (elegend == elBoth && (mat[0].legend[0] || (mat2 && mat2[0].legend[0]))) ||
             (elegend == elFirst && mat[0].legend[0]) ||
-            (elegend == elSecond && mat2[0].legend[0]) )
+            (elegend == elSecond && (mat2 && mat2[0].legend[0])) )
         {
             dhh += 2*(psr->legfontsize*FUDGE+2*DDD);
         }
@@ -973,6 +974,7 @@ void ps_mat(const char *outf, int nmat, t_matrix mat[], t_matrix mat2[],
                         }
                         else
                         {
+                            assert(mat2);
                             ps_rgb_nbox(out, &(mat2[i].map[col].rgb), nexty-y);
                         }
                     }
@@ -1030,6 +1032,7 @@ void ps_mat(const char *outf, int nmat, t_matrix mat[], t_matrix mat2[],
             }
             else
             {
+                assert(mat2);
                 leg_bicontinuous(out, x0+w/2, w, DDD, mat[0].legend, mat2[0].legend,
                                  psr->legfontsize, psr->legfont, nmap1, map1, nmap2, map2);
             }
index 168f831af39f9289073d197b85ca596e6aa337a2..2a2cf40dd5097463dd186c20fe39853bd6baa84b 100644 (file)
@@ -288,13 +288,13 @@ void gmx_init_intranode_counters(t_commrec *cr)
     if (debug)
     {
         char sbuf[STRLEN];
-        if (cr->duty & DUTY_PP && cr->duty & DUTY_PME)
+        if ((cr->duty & DUTY_PP) && (cr->duty & DUTY_PME))
         {
             sprintf(sbuf, "PP+PME");
         }
         else
         {
-            sprintf(sbuf, "%s", cr->duty & DUTY_PP ? "PP" : "PME");
+            sprintf(sbuf, "%s", (cr->duty & DUTY_PP) ? "PP" : "PME");
         }
         fprintf(debug, "On %3s rank %d: nrank_intranode=%d, rank_intranode=%d, "
                 "nrank_pp_intranode=%d, rank_pp_intranode=%d\n",
index 6b7ef86e2fccd5d707a70fbcff7218241fff0ef3..7b8f96141a3e0bacc4f214de1edd60d5acbedb68 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -44,6 +44,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <cassert>
 #include <cmath>
 
 #include <sys/types.h>
@@ -81,8 +82,10 @@ static void free_nbparam(t_nbparam **param, int nr)
 {
     int i;
 
+    assert(param);
     for (i = 0; i < nr; i++)
     {
+        assert(param[i]);
         sfree(param[i]);
     }
     sfree(param);
@@ -100,6 +103,7 @@ static int copy_nbparams(t_nbparam **param, int ftype, t_params *plist, int nr)
     {
         for (j = 0; j <= i; j++)
         {
+            assert(param);
             if (param[i][j].bSet)
             {
                 for (f = 0; f < nrfp; f++)
@@ -540,6 +544,7 @@ static void make_atoms_sys(int nmolb, const gmx_molblock_t *molb,
 
     for (mb = 0; mb < nmolb; mb++)
     {
+        assert(molb);
         mol_atoms = &molinfo[molb[mb].type].atoms;
 
         srenew(atoms->atom, atoms->nr + molb[mb].nmol*mol_atoms->nr);
index d7ff189ea0996182409dbed88340a12bd8ed88cd..10bd4a0218fef09a03bf0f0c250ff32a5a967c26 100644 (file)
@@ -489,7 +489,6 @@ void push_at (t_symtab *symtab, gpp_atomtype_t at, t_bond_atomtype bat,
         gmx_fatal(FARGS, "Invalid particle type %s on line %s",
                   ptype, line);
     }
-    /* cppcheck-suppress arrayIndexOutOfBounds #6329 */
     pt = xl[j].ptype;
     if (debug)
     {
index f486fd3ee635d1c37e5b60114294f15dff8b3f45..03185f084316873609abe9187ec32a6e034729fe 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 1991-2004 David van der Spoel, Erik Lindahl, University of Groningen.
- * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -89,10 +89,7 @@ F77_FUNC(dstqrb, DSTQRB) (int *      n,
 
     if (*n == 1)
     {
-        if (icompz == 2)
-        {
-            z__[1] = 1.;
-        }
+        z__[1] = 1.;
         return;
     }
 
@@ -106,16 +103,13 @@ F77_FUNC(dstqrb, DSTQRB) (int *      n,
     ssfmax = std::sqrt(safmax) / 3.;
     ssfmin = std::sqrt(safmin) / eps2;
 
-    if (icompz == 2)
+    i__1 = *n - 1;
+    for (j = 1; j <= i__1; ++j)
     {
-        i__1 = *n - 1;
-        for (j = 1; j <= i__1; ++j)
-        {
-            z__[j] = 0.;
+        z__[j] = 0.;
 
-        }
-        z__[*n] = 1.;
     }
+    z__[*n] = 1.;
 
     nmaxit = *n * 30;
     jtot   = 0;
@@ -2958,10 +2952,7 @@ F77_FUNC(sstqrb, SSTQRB) (int *      n,
 
     if (*n == 1)
     {
-        if (icompz == 2)
-        {
-            z__[1] = 1.;
-        }
+        z__[1] = 1.;
         return;
     }
 
@@ -2975,16 +2966,13 @@ F77_FUNC(sstqrb, SSTQRB) (int *      n,
     ssfmax = std::sqrt(safmax) / 3.;
     ssfmin = std::sqrt(safmin) / eps2;
 
-    if (icompz == 2)
+    i__1 = *n - 1;
+    for (j = 1; j <= i__1; ++j)
     {
-        i__1 = *n - 1;
-        for (j = 1; j <= i__1; ++j)
-        {
-            z__[j] = 0.;
+        z__[j] = 0.;
 
-        }
-        z__[*n] = 1.;
     }
+    z__[*n] = 1.;
 
     nmaxit = *n * 30;
     jtot   = 0;
index 80ad6074d58d9c61a02cb5808f005bfcfdadeaec..e487597bca3a8c8ebe519b6d22501114a8ec793e 100644 (file)
@@ -101,7 +101,7 @@ F77_FUNC(dlasv2,DLASV2)(double *f,
                if (std::abs(l)<GMX_DOUBLE_MIN) {
                    t = ( (ft>0) ? 2.0 : -2.0) * ( (gt>0) ? 1.0 : -1.0);
                } else {
-                   t = gt / ( (ft>0) ? d__ : d__) + m / t;
+                   t = gt / ( (ft>0) ? d__ : -d__) + m / t;
                }
            } else {
                t = (m / (s + t) + m / (r__ + l)) * (a + 1.);
index e985cdfa07d0a93d9baa4ff9560617448666a340..7293846165c383817d7baff252ab609ee7a15b84 100644 (file)
@@ -101,7 +101,7 @@ F77_FUNC(slasv2,SLASV2)(float *f,
                if (std::abs(l)<GMX_FLOAT_MIN) {
                    t = ( (ft>0) ? 2.0 : -2.0) * ( (gt>0) ? 1.0 : -1.0);
                } else {
-                   t = gt / ( (ft>0) ? d__ : d__) + m / t;
+                   t = gt / ( (ft>0) ? d__ : -d__) + m / t;
                }
            } else {
                t = (m / (s + t) + m / (r__ + l)) * (a + 1.);
index b2e10f88bdbc742552025c3e1353c1c8888a21ed..1335ad8fe2737c2184bd80247c234f564a5622f0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -84,10 +84,10 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
                          const t_inputrec *ir, gmx_mtop_t *top_global,
                          const gmx_output_env_t *oenv, gmx_wallcycle_t wcycle)
 {
-    gmx_mdoutf_t  of;
-    char          filemode[3];
-    gmx_bool      bAppendFiles, bCiteTng = FALSE;
-    int           i;
+    gmx_mdoutf_t   of;
+    const char    *appendMode = "a+", *writeMode = "w+", *filemode;
+    gmx_bool       bAppendFiles, bCiteTng = FALSE;
+    int            i;
 
     snew(of, 1);
 
@@ -113,7 +113,7 @@ gmx_mdoutf_t init_mdoutf(FILE *fplog, int nfile, const t_filenm fnm[],
 
         of->bKeepAndNumCPT = (mdrun_flags & MD_KEEPANDNUMCPT);
 
-        sprintf(filemode, bAppendFiles ? "a+" : "w+");
+        filemode = bAppendFiles ? appendMode : writeMode;
 
         if (EI_DYNAMICS(ir->eI) &&
             ir->nstxout_compressed > 0)
index 977d876ed004c6c819b5040ba77e753bf9fed5af..b581115be72df165e58bd20fa52ab8ac2b3137f5 100644 (file)
@@ -1126,7 +1126,7 @@ double do_cg(FILE *fplog, t_commrec *cr,
      * we either converge or reach the max number of steps.
      */
     converged = FALSE;
-    for (step = 0; (number_steps < 0 || (number_steps >= 0 && step <= number_steps)) && !converged; step++)
+    for (step = 0; (number_steps < 0 || step <= number_steps) && !converged; step++)
     {
 
         /* start taking steps in a new direction
@@ -1886,7 +1886,7 @@ double do_lbfgs(FILE *fplog, t_commrec *cr,
 
     /* Set the gradient from the force */
     converged = FALSE;
-    for (step = 0; (number_steps < 0 || (number_steps >= 0 && step <= number_steps)) && !converged; step++)
+    for (step = 0; (number_steps < 0 || step <= number_steps) && !converged; step++)
     {
 
         /* Write coordinates if necessary */
index 63915fa0a1df80ce587659e0a0e93c054853b3e1..c60b4168899cea858aada6ea238593ad79782a83 100644 (file)
@@ -637,259 +637,6 @@ void nbnxn_gpu_launch_kernel(gmx_nbnxn_ocl_t               *nb,
     }
 #endif
 }
-
-/*! \brief Debugging helper function */
-void dump_compare_results_cj4(nbnxn_cj4_t* results, int cnt, char* out_file, char* ref_file)
-{
-    FILE *pf;
-
-    pf = fopen(out_file, "wt");
-    assert(pf != NULL);
-
-    fprintf(pf, "%20s%20s%20s%20s%20s%20s%20s%20s\n",
-            "cj[0]", "cj[1]", "cj[2]", "cj[3]",
-            "imei[0].excl_ind", "imei[0].imask",
-            "imei[1].excl_ind", "imei[1].imask");
-
-    for (int index = 0; index < cnt; index++)
-    {
-        fprintf(pf, "%20d%20d%20d%20d%20d%20u%20d%20u\n",
-                results[index].cj[0], results[index].cj[1], results[index].cj[2], results[index].cj[3],
-                results[index].imei[0].excl_ind, results[index].imei[0].imask,
-                results[index].imei[1].excl_ind, results[index].imei[1].imask);
-    }
-
-    fclose(pf);
-
-    printf("\nWrote results to %s", out_file);
-
-    pf = fopen(ref_file, "rt");
-    if (pf)
-    {
-        char c;
-        int  diff = 0;
-        printf("\n%s file found. Comparing results...", ref_file);
-
-        /* Skip the first line */
-        c = 0;
-        while (c != '\n')
-        {
-            if (1 != fscanf(pf, "%c", &c))
-            {
-                break;
-            }
-        }
-
-        for (int index = 0; index < cnt; index++)
-        {
-            int          ref_val;
-            unsigned int u_ref_val;
-
-            for (int j = 0; j < 4; j++)
-            {
-                if (1 != fscanf(pf, "%20d", &ref_val))
-                {
-                    break;
-                }
-
-                if (ref_val != results[index].cj[j])
-                {
-                    printf("\nDifference for cj[%d] at index %d computed value = %d reference value = %d",
-                           j, index, results[index].cj[j], ref_val);
-
-                    diff++;
-                }
-            }
-
-            for (int j = 0; j < 2; j++)
-            {
-                if (1 != fscanf(pf, "%20d", &ref_val))
-                {
-                    break;
-                }
-
-                if (ref_val != results[index].imei[j].excl_ind)
-                {
-                    printf("\nDifference for imei[%d].excl_ind at index %d computed value = %d reference value = %d",
-                           j, index, results[index].imei[j].excl_ind, ref_val);
-
-                    diff++;
-                }
-
-                if (1 != fscanf(pf, "%20u", &u_ref_val))
-                {
-                    break;
-                }
-
-                if (u_ref_val != results[index].imei[j].imask)
-                {
-                    printf("\nDifference for imei[%d].imask at index %d computed value = %u reference value = %u",
-                           j, index, results[index].imei[j].imask, u_ref_val);
-
-                    diff++;
-                }
-
-            }
-        }
-
-        printf("\nFinished comparing results. Total number of differences: %d", diff);
-        fclose(pf);
-    }
-    else
-    {
-        printf("\n%s file not found. No comparison performed.", ref_file);
-    }
-}
-
-/*! \brief Debugging helper function */
-void dump_compare_results_f(float* results, int cnt, char* out_file, char* ref_file)
-{
-    FILE *pf;
-    float cmp_eps = 0.001f;
-
-    pf = fopen(out_file, "wt");
-    assert(pf != NULL);
-
-    for (int index = 0; index < cnt; index++)
-    {
-        fprintf(pf, "%15.5f\n", results[index]);
-    }
-
-    fclose(pf);
-
-    printf("\nWrote results to %s", out_file);
-
-    pf = fopen(ref_file, "rt");
-    if (pf)
-    {
-        int diff = 0;
-        printf("\n%s file found. Comparing results...", ref_file);
-        for (int index = 0; index < cnt; index++)
-        {
-            float ref_val;
-            if (1 != fscanf(pf, "%20f", &ref_val))
-            {
-                break;
-            }
-
-            if (((ref_val - results[index]) > cmp_eps) ||
-                ((ref_val - results[index]) < -cmp_eps))
-            {
-                printf("\nDifference at index %d computed value = %15.5f reference value = %15.5f",
-                       index, results[index], ref_val);
-
-                diff++;
-            }
-        }
-
-        printf("\nFinished comparing results. Total number of differences: %d", diff);
-        fclose(pf);
-    }
-    else
-    {
-        printf("\n%s file not found. No comparison performed.", ref_file);
-    }
-}
-
-/*! \brief
- * Debug function for dumping cj4, f and fshift buffers.
- * By default this function does nothing. To enable debugging for any of these
- * buffers, uncomment the corresponding definition inside the function:
- * DEBUG_DUMP_CJ4_OCL, DEBUG_DUMP_F_OCL, DEBUG_DUMP_FSHIFT_OCL.
- */
-static
-void debug_dump_cj4_f_fshift(gmx_nbnxn_ocl_t               gmx_unused *nb,
-                             const struct nbnxn_atomdata_t gmx_unused *nbatom,
-                             cl_command_queue              gmx_unused  stream,
-                             int                           gmx_unused  adat_begin,
-                             int                           gmx_unused  adat_len)
-{
-/* Uncomment this define to enable cj4 debugging for the first kernel run */
-//#define DEBUG_DUMP_CJ4_OCL
-#ifdef DEBUG_DUMP_CJ4_OCL
-    {
-        static int run_step = 1;
-
-        if (DEBUG_RUN_STEP == run_step)
-        {
-            nbnxn_cj4_t *temp_cj4;
-            int          cnt;
-            size_t       size;
-            char         ocl_file_name[256]  = {0};
-            char         cuda_file_name[256] = {0};
-
-            cnt      = nb->plist[0]->ncj4;
-            size     = cnt * sizeof(nbnxn_cj4_t);
-            temp_cj4 = (nbnxn_cj4_t*)malloc(size);
-
-            ocl_copy_D2H_async(temp_cj4, nb->plist[0]->cj4, 0,
-                               size, stream, NULL);
-
-            // Make sure all data has been transfered back from device
-            clFinish(stream);
-
-            sprintf(ocl_file_name, "ocl_cj4_%d.txt", DEBUG_RUN_STEP);
-            sprintf(cuda_file_name, "cuda_cj4_%d.txt", DEBUG_RUN_STEP);
-            dump_compare_results_cj4(temp_cj4, cnt, ocl_file_name, cuda_file_name);
-
-            free(temp_cj4);
-        }
-
-        run_step++;
-    }
-#endif
-
-/* Uncomment this define to enable f debugging for the first kernel run */
-//#define DEBUG_DUMP_F_OCL
-#ifdef DEBUG_DUMP_F_OCL
-    {
-        static int run_step = 1;
-
-        if (DEBUG_RUN_STEP == run_step)
-        {
-            char ocl_file_name[256]  = {0};
-            char cuda_file_name[256] = {0};
-
-            // Make sure all data has been transfered back from device
-            clFinish(stream);
-
-            sprintf(ocl_file_name, "ocl_f_%d.txt", DEBUG_RUN_STEP);
-            sprintf(cuda_file_name, "cuda_f_%d.txt", DEBUG_RUN_STEP);
-
-            dump_compare_results_f(nbatom->out[0].f + adat_begin * 3, (adat_len) * 3,
-                                   ocl_file_name, cuda_file_name);
-        }
-
-        run_step++;
-    }
-#endif
-
-/* Uncomment this define to enable fshift debugging for the first kernel run */
-//#define DEBUG_DUMP_FSHIFT_OCL
-#ifdef DEBUG_DUMP_FSHIFT_OCL
-    {
-        static int run_step = 1;
-
-        if (DEBUG_RUN_STEP == run_step)
-        {
-            char ocl_file_name[256]  = {0};
-            char cuda_file_name[256] = {0};
-
-            // Make sure all data has been transfered back from device
-            clFinish(stream);
-
-            sprintf(ocl_file_name, "ocl_fshift_%d.txt", DEBUG_RUN_STEP);
-            sprintf(cuda_file_name, "cuda_fshift_%d.txt", DEBUG_RUN_STEP);
-
-            dump_compare_results_f((float*)(nb->nbst.fshift), SHIFTS * 3,
-                                   ocl_file_name, cuda_file_name);
-        }
-
-        run_step++;
-    }
-#endif
-}
-
 /*! \brief
  * Launch asynchronously the download of nonbonded forces from the GPU
  * (and energies/shift forces if required).
@@ -1009,8 +756,6 @@ void nbnxn_gpu_launch_cpyback(gmx_nbnxn_ocl_t               *nb,
                                sizeof(float), stream, bDoTime ? &(t->nb_d2h_e_el[iloc]) : NULL);
         }
     }
-
-    debug_dump_cj4_f_fshift(nb, nbatom, stream, adat_begin, adat_len);
 }
 
 /*! \brief
index 15112a50fc2cc14cbb786e9c58b170c39897f1f7..7541b14ee99c8e330977b9d20c0db57f52096d05 100644 (file)
@@ -4124,7 +4124,7 @@ void nbnxn_make_pairlist(const nbnxn_search_t  nbs,
         nbs->search_count++;
     }
     if (nbs->print_cycles &&
-        (!nbs->DomDec || (nbs->DomDec && !LOCAL_I(iloc))) &&
+        (!nbs->DomDec || !LOCAL_I(iloc)) &&
         nbs->search_count % 100 == 0)
     {
         nbs_cycle_print(stderr, nbs);
index d7cb5cf6c97d521afd9e80ca313d91ba7534dff0..108841e9cfa9d81904331d6c51d68ae190b2a5b1 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -361,6 +361,7 @@ OptionStorageTemplate<T>::OptionStorageTemplate(const OptionTemplate<T, U> &sett
 
 
 template <typename T>
+// cppcheck-suppress uninitMemberVar
 OptionStorageTemplate<T>::OptionStorageTemplate(const AbstractOption &settings)
     : AbstractOptionStorage(settings, OptionFlags()),
       store_(NULL), countptr_(NULL),
index 09a1763e94ec2dda4830becb6a4b01f8eef23970..4ca2010fe7d4380206c8bd237843e6a8fcc62b0b 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -622,9 +622,9 @@ _gmx_sel_init_arithmetic(const gmx::SelectionTreeElementPointer &left,
         case '/': sel->u.arith.type = ARITH_DIV;  break;
         case '^': sel->u.arith.type = ARITH_EXP;  break;
     }
-    char               buf[2];
-    buf[0] = op;
-    buf[1] = 0;
+    char               buf[2] {
+        op, 0
+    };
     sel->setName(buf);
     sel->u.arith.opstr = gmx_strdup(buf);
     sel->child         = left;
@@ -923,16 +923,15 @@ _gmx_sel_init_position(const gmx::SelectionTreeElementPointer &expr,
 SelectionTreeElementPointer
 _gmx_sel_init_const_position(real x, real y, real z, yyscan_t scanner)
 {
-    rvec                        pos;
+    rvec                        pos {
+        x, y, z
+    };
 
     SelectionTreeElementPointer sel(
             new SelectionTreeElement(
                     SEL_CONST, _gmx_sel_lexer_get_current_location(scanner)));
     _gmx_selelem_set_vtype(sel, POS_VALUE);
     _gmx_selvalue_reserve(&sel->v, 1);
-    pos[XX] = x;
-    pos[YY] = y;
-    pos[ZZ] = z;
     gmx_ana_pos_init_const(sel->v.u.p, pos);
     return sel;
 }
index 872183a077b396e587577eaccc58e4b8afc80e96..79d915f58625fc4d2fdd7f891908fd06d6c0654e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -396,9 +396,13 @@ _gmx_sel_init_lexer(yyscan_t *scannerp, struct gmx_ana_selcollection_t *sc,
 
     gmx_sel_lexer_t *state = new gmx_sel_lexer_t;
 
+    // cppcheck-suppress uninitdata
     state->sc        = sc;
+    // cppcheck-suppress uninitdata
     state->bGroups   = bGroups;
+    // cppcheck-suppress uninitdata
     state->grps      = grps;
+    // cppcheck-suppress uninitdata
     state->nexpsel   = (maxnr > 0 ? static_cast<int>(sc->sel.size()) + maxnr : -1);
 
     state->statusWriter = statusWriter;
index d8e6e7823468f3109c659b79ee564ffe625d84e5..196a6575eb84a89ead8134c2c7cb90f64c1487dc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2009,2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -374,17 +374,27 @@ static void *
 init_data_insolidangle(int /* npar */, gmx_ana_selparam_t *param)
 {
     t_methoddata_insolidangle *data = new t_methoddata_insolidangle();
+    // cppcheck-suppress uninitdata
     data->angcut        = 5.0;
+    // cppcheck-suppress uninitdata
     data->cfrac         = 0.0;
 
+    // cppcheck-suppress uninitdata
     data->distccut      = 0.0;
+    // cppcheck-suppress uninitdata
     data->targetbinsize = 0.0;
 
+    // cppcheck-suppress uninitdata
     data->ntbins        = 0;
+    // cppcheck-suppress uninitdata
     data->tbinsize      = 0.0;
+    // cppcheck-suppress uninitdata
     data->tbin          = NULL;
+    // cppcheck-suppress uninitdata
     data->maxbins       = 0;
+    // cppcheck-suppress uninitdata
     data->nbins         = 0;
+    // cppcheck-suppress uninitdata
     data->bin           = NULL;
 
     param[0].val.u.p = &data->center;
index 44000946c69db49da966989e54ae143cc4a37c8b..8936290257e3e4fdfd049951911864eccbedc634 100644 (file)
@@ -249,7 +249,7 @@ static void pr_atom(FILE *fp, int indent, const char *title, const t_atom *atom,
         for (i = 0; i < n; i++)
         {
             pr_indent(fp, indent);
-            fprintf(fp, "%s[%6d]={type=%3d, typeB=%3d, ptype=%8s, m=%12.5e, "
+            fprintf(fp, "%s[%6d]={type=%3u, typeB=%3u, ptype=%8s, m=%12.5e, "
                     "q=%12.5e, mB=%12.5e, qB=%12.5e, resind=%5d, atomnumber=%3d}\n",
                     title, i, atom[i].type, atom[i].typeB, ptype_str[atom[i].ptype],
                     atom[i].m, atom[i].q, atom[i].mB, atom[i].qB,
index 32a3c5cef2a6e2c2e7ed9479d7f34bca520882c1..ef7ec745e626b2b40126e3e6d6af7eb06c583b03 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -265,6 +265,7 @@ static void analyse_other(const char ** restype, t_atoms *atoms,
 
                 for (l = 0; (l < nrestp); l++)
                 {
+                    assert(restp);
                     if (strcmp(restp[l].rname, rname) == 0)
                     {
                         break;
@@ -606,24 +607,35 @@ void analyse(t_atoms *atoms, t_blocka *gb, char ***gn, gmx_bool bASK, gmx_bool b
     snew(restype, atoms->nres);
     ntypes     = 0;
     p_typename = NULL;
-    for (i = 0; i < atoms->nres; i++)
+    if (atoms->nres > 0)
     {
+        int i = 0;
+
         resnm = *atoms->resinfo[i].name;
         gmx_residuetype_get_type(rt, resnm, &(restype[i]));
+        snew(p_typename, ntypes+1);
+        p_typename[ntypes] = gmx_strdup(restype[i]);
+        ntypes++;
 
-        /* Note that this does not lead to a N*N loop, but N*K, where
-         * K is the number of residue _types_, which is small and independent of N.
-         */
-        found = 0;
-        for (k = 0; k < ntypes && !found; k++)
-        {
-            assert(p_typename != NULL);
-            found = !strcmp(restype[i], p_typename[k]);
-        }
-        if (!found)
+        for (i = 1; i < atoms->nres; i++)
         {
-            srenew(p_typename, ntypes+1);
-            p_typename[ntypes++] = gmx_strdup(restype[i]);
+            resnm = *atoms->resinfo[i].name;
+            gmx_residuetype_get_type(rt, resnm, &(restype[i]));
+
+            /* Note that this does not lead to a N*N loop, but N*K, where
+             * K is the number of residue _types_, which is small and independent of N.
+             */
+            found = 0;
+            for (k = 0; k < ntypes && !found; k++)
+            {
+                found = !strcmp(restype[i], p_typename[k]);
+            }
+            if (!found)
+            {
+                srenew(p_typename, ntypes+1);
+                p_typename[ntypes] = gmx_strdup(restype[i]);
+                ntypes++;
+            }
         }
     }
 
index 9919b04c6a688746a3a3b50825ee72d5fc041d08..0edae2ac89cfe54bec4b7ea3f86b76d42620e58e 100644 (file)
@@ -407,11 +407,11 @@ void gmx_mtop_atominfo_global(const gmx_mtop_t *mtop, int atnr_global,
     {
         if (mb >= 0)
         {
-            /* cppcheck-suppress nullPointer #6330*/
+            /* cppcheck-suppress nullPointer #6330 will be fixed in cppcheck 1.73 */
             if (atoms->nres <= mtop->maxres_renum)
             {
                 /* Single residue molecule, keep counting */
-                /* cppcheck-suppress nullPointer #6330*/
+                /* cppcheck-suppress nullPointer #6330 will be fixed in cppcheck 1.73 */
                 maxresnr += mtop->molblock[mb].nmol*atoms->nres;
             }
         }
index 4c845cc91c365d0723138de97b05c88d4ac50b69..50485b318f8c0c1365945114c4019d39802fbdb9 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -157,25 +157,31 @@ gmx_residuetype_get_alltypes(gmx_residuetype_t   *rt,
                              const char ***       p_typenames,
                              int *                ntypes)
 {
-    int            i, n;
-    const char **  my_typename;
+    int          n           = 0;
+    const char **my_typename = NULL;
 
-    n           = 0;
-    my_typename = NULL;
-    for (i = 0; i < rt->n; i++)
+    if (rt->n > 0)
     {
-        const char *const p      = rt->restype[i];
-        bool              bFound = false;
-        for (int j = 0; j < n && !bFound; j++)
-        {
-            assert(my_typename != NULL);
-            bFound = !gmx_strcasecmp(p, my_typename[j]);
-        }
-        if (!bFound)
+        int         i = 0;
+        const char *p = rt->restype[i];
+        snew(my_typename, n+1);
+        my_typename[n] = p;
+        n              = 1;
+
+        for (i = 1; i < rt->n; i++)
         {
-            srenew(my_typename, n+1);
-            my_typename[n] = p;
-            n++;
+            p = rt->restype[i];
+            bool bFound = false;
+            for (int j = 0; j < n && !bFound; j++)
+            {
+                bFound = !gmx_strcasecmp(p, my_typename[j]);
+            }
+            if (!bFound)
+            {
+                srenew(my_typename, n+1);
+                my_typename[n] = p;
+                n++;
+            }
         }
     }
     *ntypes      = n;
index 46edbc9a7c0ae03ead8e71f352dd8ae933b292bd..4304efd0a7732a587d9ebb3dde3a018c8e4af659 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2011,2012,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2011,2012,2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -766,14 +766,20 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
                     rvec dx[3];
                     if (pbc)
                     {
+                        // cppcheck-suppress uninitvar
                         pbc_dx(pbc, x[0], x[1], dx[0]);
+                        // cppcheck-suppress uninitvar
                         pbc_dx(pbc, x[2], x[1], dx[1]);
+                        // cppcheck-suppress uninitvar
                         pbc_dx(pbc, x[2], x[3], dx[2]);
                     }
                     else
                     {
+                        // cppcheck-suppress uninitvar
                         rvec_sub(x[0], x[1], dx[0]);
+                        // cppcheck-suppress uninitvar
                         rvec_sub(x[2], x[1], dx[1]);
+                        // cppcheck-suppress uninitvar
                         rvec_sub(x[2], x[3], dx[2]);
                     }
                     cprod(dx[0], dx[1], v1);
index 74f133e5d7d44dec1a29ce06be4da1959d156e9c..3e20b0d9c3b5eb392f782e66f42cbeddc38eefc4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -343,6 +343,7 @@ FreeVolume::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc,
         for (int m = 0; (m < DIM); m++)
         {
             // Generate random number between 0 and 1
+            // cppcheck-suppress uninitvar
             rand[m] = gmx_rng_uniform_real(rng_);
         }
         // Generate random 3D position within the box
index a46b7874a34606eec11f31025956b258d1e137a9..2ed120638e028cfa4cb8bfbe88b0ac5a559dc0c9 100644 (file)
@@ -79,7 +79,7 @@ namespace gmx
 class TrajectoryAnalysisRunnerCommon::Impl : public ITopologyProvider
 {
     public:
-        Impl(TrajectoryAnalysisSettings *settings);
+        explicit Impl(TrajectoryAnalysisSettings *settings);
         ~Impl();
 
         bool hasTrajectory() const { return !trjfile_.empty(); }
index 4a3d3909d001be16fdbb67ffd0db6dc450ebac8e..974688cdbee435f1ea167e49d97570c430c86aed 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2015, by the GROMACS development team, led by
+ * Copyright (c) 2015,2016, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
@@ -58,7 +58,7 @@ namespace
 class InteractiveSession
 {
     public:
-        InteractiveSession(gmx::test::ReferenceDataMode mode)
+        explicit InteractiveSession(gmx::test::ReferenceDataMode mode)
             : data_(mode), helper_(data_.rootChecker()), nextInputLine_(0)
         {
         }
index 6cbf3c1363d01062f39385c8cc2d3d1ddd88c279..0500bafe8b52fdf9944b7d0cfd3c1bf8139c1faf 100644 (file)
@@ -1,7 +1,7 @@
 #
 # This file is part of the GROMACS molecular simulation package.
 #
-# Copyright (c) 2013,2014,2015, by the GROMACS development team, led by
+# Copyright (c) 2013,2014,2015,2016, by the GROMACS development team, led by
 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
 # and including many others, as listed in the AUTHORS file in the
 # top-level source directory and at http://www.gromacs.org.
@@ -59,12 +59,13 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         ${CMAKE_SOURCE_DIR}/src/external/*.cu
         ${CMAKE_SOURCE_DIR}/src/gromacs/selection/scanner.cpp
         ${CMAKE_SOURCE_DIR}/src/gromacs/selection/parser.cpp
+        ${CMAKE_SOURCE_DIR}/src/gromacs/gpu_utils/ocl_compiler.cpp
         )
     list(REMOVE_ITEM _inputfiles ${_files_to_ignore})
 
     # Set flags for cppcheck
     set(_outputext txt)
-    set(_outputopt --template=gcc)
+    set(_outputopt "--template={file}:{line}:{id}: {severity}: {message}")
     if (CPPCHECK_XML_OUTPUT)
         set(_outputext xml)
         set(_outputopt --xml --xml-version=2)
@@ -92,6 +93,7 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         --suppress=invalidPointerCast:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
         --suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel.cuh
         --suppress=passedByValue:src/gromacs/mdlib/nbnxn_cuda/nbnxn_cuda_kernel_utils.cuh
+        --suppress=shiftTooManyBits:src/gromacs/gpu_utils/gpu_utils.cu
         ) 
     set(_cxx_flags
         -D__cplusplus
@@ -101,7 +103,8 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         --suppress=invalidscanf_libc #seems only important for security on non-std libc
         --suppress=invalidscanf      #same as last (style and portability checker have the same warning)
         --suppress=passedByValue:src/gromacs/simd/tests/*
-        --suppress=redundantAssignment:src/gromacs/simd/simd_math.h #sees to be a bug in cppcheck
+        --suppress=redundantAssignment:src/gromacs/simd/simd_math.h #seems to be a bug in cppcheck
+        --suppress=noExplicitConstructor # can't be selective about this, see http://sourceforge.net/p/cppcheck/discussion/general/thread/db1e4ba7/
         )
 
     # This list will hold the list of all files with cppcheck errors