Update cppcheck support to 1.76.1
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 18 Oct 2016 15:32:06 +0000 (17:32 +0200)
committerMark Abraham <mark.j.abraham@gmail.com>
Fri, 21 Oct 2016 07:59:24 +0000 (09:59 +0200)
Suppressed some classes of warnings where cppcheck was systematically
failing (for at least some source files). Added assert statements
to cover others.

Propagated some const correctness.

Replaced some block_* macros with templated functions in a header
that we re-use in a few places.

The gmx_arpack and lapack issues were inherited from the original
FORTRAN.

The simd/support.cpp issue is a bug that is fixed in release-2016.

Removed some unnecessary stderr output.

Noted TODOs for further cleanup.

Change-Id: Ia93690e3dbd529ef27e5b7f8331d12a2f7d34766

45 files changed:
admin/builds/cppcheck.py
src/gromacs/commandline/pargs.cpp
src/gromacs/domdec/domdec_topology.cpp
src/gromacs/essentialdynamics/edsam.cpp
src/gromacs/fft/fft_fftpack.cpp
src/gromacs/fft/fft_mkl.cpp
src/gromacs/fileio/enxio.cpp
src/gromacs/fileio/oenv.cpp
src/gromacs/fileio/tpxio.cpp
src/gromacs/fileio/xvgr.cpp
src/gromacs/gmxana/binsearch.cpp
src/gromacs/gmxana/gmx_anaeig.cpp
src/gromacs/gmxana/gmx_cluster.cpp
src/gromacs/gmxana/gmx_mindist.cpp
src/gromacs/gmxana/gmx_pme_error.cpp
src/gromacs/gmxana/gmx_rmsf.cpp
src/gromacs/gmxana/gmx_wham.cpp
src/gromacs/gmxana/nrama.cpp
src/gromacs/gmxana/nsfactor.cpp
src/gromacs/gmxpreprocess/convparm.cpp
src/gromacs/gmxpreprocess/gen_ad.cpp
src/gromacs/gmxpreprocess/grompp-impl.h
src/gromacs/gmxpreprocess/h_db.cpp
src/gromacs/gmxpreprocess/pdb2top.cpp
src/gromacs/gmxpreprocess/resall.cpp
src/gromacs/imd/imd.cpp
src/gromacs/linearalgebra/gmx_arpack.cpp
src/gromacs/linearalgebra/gmx_lapack/dstebz.cpp
src/gromacs/linearalgebra/gmx_lapack/sstebz.cpp
src/gromacs/mdlib/broadcaststructs.cpp
src/gromacs/mdlib/broadcaststructs.h [new file with mode: 0644]
src/gromacs/mdlib/forcerec.cpp
src/gromacs/mdlib/gmx_omp_nthreads.cpp
src/gromacs/mdlib/mdebin_bar.cpp
src/gromacs/mdlib/nbnxn_kernels/nbnxn_kernel_ref_inner.h
src/gromacs/options/valuestore.h
src/gromacs/selection/centerofmass.cpp
src/gromacs/selection/selelem.cpp
src/gromacs/simd/support.cpp
src/gromacs/topology/index.cpp
src/gromacs/topology/symtab.cpp
src/programs/view/dialogs.cpp
src/programs/view/manager.cpp
src/programs/view/nmol.cpp
tests/CppCheck.cmake

index 85711e98b1e86b6db5eabda9ffe616a4629daf10..d3cea58da8866684dcb30efd513fa6b0fb050002 100644 (file)
@@ -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.72'),
+            'CPPCHECK_EXECUTABLE': context.env.get_cppcheck_command(version='1.76.1'),
             'CPPCHECK_XML_OUTPUT': 'ON',
             'GMX_SIMD': 'Reference'
         }
index 38052ac57c3deedc8b21a39d6991125b9c936fff..dcbb501dc26947e58930554c225334a0414e01a2 100644 (file)
@@ -210,7 +210,7 @@ int getDefaultXvgFormat(gmx::ConstArrayRef<const char *> xvgFormats)
             std::find(xvgFormats.begin(), xvgFormats.end(), std::string(select));
         if (i != xvgFormats.end())
         {
-            return i - xvgFormats.begin();
+            return std::distance(xvgFormats.begin(), i);
         }
         else
         {
index 28666053ba6c7b70bd5f29d0656ff304bf42ae17..79062a81225e793f21e924e7bf0f566078cbb716 100644 (file)
@@ -49,6 +49,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <cassert>
+
 #include <algorithm>
 #include <string>
 
@@ -503,7 +505,7 @@ static void count_excls(const t_block *cgs, const t_blocka *excls,
     }
 }
 
-/*! \brief Run the reverse ilist generation and store it when \p bAssign = TRUE */
+/*! \brief Run the reverse ilist generation and store it in r_il when \p bAssign = TRUE */
 static int low_make_reverse_ilist(const t_ilist *il_mt, const t_atom *atom,
                                   const int * const * vsite_pbc,
                                   int *count,
@@ -555,6 +557,8 @@ static int low_make_reverse_ilist(const t_ilist *il_mt, const t_atom *atom,
                     a = ia[1+link];
                     if (bAssign)
                     {
+                        assert(r_il); //with bAssign not allowed to be null
+                        assert(r_index);
                         r_il[r_index[a]+count[a]] =
                             (ftype == F_CONSTRNC ? F_CONSTR : ftype);
                         r_il[r_index[a]+count[a]+1] = ia[0];
index 7658c74210d9f09bfd1a07cacb4f60d8f2b2d013..df8e76e4452ee820192d4545ea039e559fcdc5d1 100644 (file)
@@ -53,6 +53,7 @@
 #include "gromacs/math/utilities.h"
 #include "gromacs/math/vec.h"
 #include "gromacs/math/vectypes.h"
+#include "gromacs/mdlib/broadcaststructs.h"
 #include "gromacs/mdlib/groupcoord.h"
 #include "gromacs/mdlib/mdrun.h"
 #include "gromacs/mdlib/sim_util.h"
 #include "gromacs/utility/smalloc.h"
 
 
-/* We use the same defines as in broadcaststructs.cpp here */
-#define  block_bc(cr,   d) gmx_bcast(     sizeof(d),     &(d), (cr))
-#define nblock_bc(cr, nr, d) gmx_bcast((nr)*sizeof((d)[0]), (d), (cr))
-#define   snew_bc(cr, d, nr) { if (!MASTER(cr)) {snew((d), (nr)); }}
-
 /* enum to identify the type of ED: none, normal ED, flooding */
 enum {
     eEDnone, eEDedsam, eEDflood, eEDnr
index ac194ab3e9e1241bd7eb94171927998b974bb225..9a55150b6f003470861fa8b789d82aaa93785957 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the GROMACS molecular simulation package.
  *
  * Copyright (c) 1991-2003 David van der Spoel, Erik Lindahl, University of Groningen.
- * 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.
@@ -391,7 +391,7 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
                 }
             }
         }
-        data = (t_complex *)out_data;
+        data = static_cast<t_complex *>(out_data);
 
         /* y real-to-complex FFTs */
         for (i = 0; i < nx; i++)
@@ -425,12 +425,12 @@ gmx_fft_2d_real          (gmx_fft_t                  fft,
         if (in_data != out_data)
         {
             memcpy(work, in_data, sizeof(t_complex)*nx*nyc);
-            data = (t_complex *)work;
+            data = reinterpret_cast<t_complex *>(work);
         }
         else
         {
             /* in-place */
-            data = (t_complex *)out_data;
+            data = reinterpret_cast<t_complex *>(out_data);
         }
 
         /* Transpose to get X arrays */
index 9eede3a3310d99a2c606935122adeddbab856334..a120ee5d00e4b9f20034dab0ce085d2b50cbc237 100644 (file)
@@ -424,10 +424,12 @@ gmx_fft_init_2d_real(gmx_fft_t *             pfft,
 
     if (status == 0)
     {
-        if ((fft->work = (t_complex *)malloc(sizeof(t_complex)*(nx*(ny/2+1)))) == NULL)
+        void *memory = malloc(sizeof(t_complex)*(nx*(ny/2+1)));
+        if (nullptr == memory)
         {
             status = ENOMEM;
         }
+        fft->work = static_cast<t_complex *>(memory);
     }
 
     if (status != 0)
index 7ff5840ea994b47d17351ba626716309ed6b763a..6dc3619ffc4ba516a5d942e2f0bde3d98b75189c 100644 (file)
@@ -252,8 +252,6 @@ void init_enxframe(t_enxframe *fr)
     fr->ener    = NULL;
 
     /*fr->d_alloc=0;*/
-    fr->ener = NULL;
-
     /*fr->ndisre=0;*/
 
     fr->nblock       = 0;
@@ -498,6 +496,7 @@ static gmx_bool do_eheader(ener_file_t ef, int *file_version, t_enxframe *fr,
             return FALSE;
         }
         *file_version = enx_version;
+        // cppcheck-suppress redundantPointerOp
         if (!gmx_fio_do_int(ef->fio, *file_version))
         {
             *bOK = FALSE;
index a00699208499f533fd58515c998aab96a414fadf..fcc648f576e473fb624dd50881ce0091155b2cca 100644 (file)
 struct gmx_output_env_t
 {
     explicit gmx_output_env_t(const gmx::IProgramContext &context)
-        : programContext(context)
-    {
-        time_unit   = time_ps;
-        view        = FALSE;
-        xvg_format  = exvgNONE;
-        verbosity   = 0;
-    }
+        : programContext(context),
+          time_unit(time_ps),
+          view(FALSE),
+          xvg_format(exvgNONE),
+          verbosity(0) {}
 
     const gmx::IProgramContext  &programContext;
 
index 5ba8a74cb93cbfa4bf60c2ddde532d2e444ef66e..c85e1530ddc545f716ae94e92ea1e2c3eeb9a58e 100644 (file)
@@ -1313,6 +1313,7 @@ static void do_inputrec(t_fileio *fio, t_inputrec *ir, gmx_bool bRead,
     gmx_fio_do_real(fio, ir->shake_tol);
     if (file_version < 54)
     {
+        // cppcheck-suppress redundantPointerOp
         gmx_fio_do_real(fio, *fudgeQQ);
     }
 
index 6034a4f811eaa2e3f3cc8155647d2f9e9d8a494d..db6e22421dabd15ddd91b2c9cbd6c7252b62dfad 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.
@@ -38,6 +38,7 @@
 
 #include "xvgr.h"
 
+#include <cassert>
 #include <cctype>
 #include <cstring>
 
@@ -692,6 +693,7 @@ int read_xvg_legend(const char *fn, double ***y, int *ny,
     {
         if (*ny - 1 > legend_nalloc)
         {
+            assert(legend);
             srenew(*legend, *ny-1);
             for (set = legend_nalloc; set < *ny-1; set++)
             {
index 1c9f474d14e6cdd946f38f2d8db0da4f636e1c49..74f1514265e4e39d2769f38868e8a083dcb2ca27 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2010,2011,2013,2014,2015, by the GROMACS development team, led by
+ * Copyright (c) 2010,2011,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.
@@ -133,8 +133,7 @@ int BinarySearch (real *array, int low, int high, real key, int direction)
         }
         return iMin;
     }
-
-    else if (direction < 0)
+    else
     {
         while (iMax-iMin > 1)
         {
@@ -149,9 +148,7 @@ int BinarySearch (real *array, int low, int high, real key, int direction)
             }
         }
         return iMin-1;
-
-    } /*end -ifelse direction*/
-    return -1;
+    }
 }
 
 
@@ -181,7 +178,7 @@ int LinearSearch (double *array, int startindx, int stopindx,
             }
         }
     }
-    else if (direction < 0)
+    else
     {
         for (i = stopindx; i >= startindx; i--)
         {
@@ -194,10 +191,5 @@ int LinearSearch (double *array, int startindx, int stopindx,
         }
     }
 
-    else
-    {
-        gmx_fatal(FARGS, "Startindex=stopindex=%d\n", startindx);
-    }
-
     return -1;
 }
index 15fbfb13f403129bd9c1959b6a8406e4009f6c8f..28971476152d63c09af61a42dd258221de48824f 100644 (file)
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cassert>
 #include <cmath>
 #include <cstdlib>
 #include <cstring>
@@ -180,6 +181,7 @@ static void write_xvgr_graphs(const char *file, int ngraphs, int nsetspergraph,
         }
         else
         {
+            assert(sy);
             ymin = sy[g][0][0];
             ymax = sy[g][0][0];
             for (s = 0; s < nsetspergraph; s++)
index 4df864b0a880eb88eb93188469fe7f966370209b..dd621875495fab073a1f59de75415015ece86f76 100644 (file)
@@ -332,10 +332,10 @@ static real rms_dist(int isize, real **d, real **d_r)
 
 static int rms_dist_comp(const void *a, const void *b)
 {
-    t_dist *da, *db;
+    const t_dist *da, *db;
 
-    da = (t_dist *)a;
-    db = (t_dist *)b;
+    da = static_cast<const t_dist *>(a);
+    db = static_cast<const t_dist *>(b);
 
     if (da->dist - db->dist < 0)
     {
@@ -350,20 +350,20 @@ static int rms_dist_comp(const void *a, const void *b)
 
 static int clust_id_comp(const void *a, const void *b)
 {
-    t_clustid *da, *db;
+    const t_clustid *da, *db;
 
-    da = (t_clustid *)a;
-    db = (t_clustid *)b;
+    da = static_cast<const t_clustid *>(a);
+    db = static_cast<const t_clustid *>(b);
 
     return da->clust - db->clust;
 }
 
 static int nrnb_comp(const void *a, const void *b)
 {
-    t_nnb *da, *db;
+    const t_nnb *da, *db;
 
-    da = (t_nnb *)a;
-    db = (t_nnb *)b;
+    da = static_cast<const t_nnb *>(a);
+    db = static_cast<const t_nnb *>(b);
 
     /* return the b-a, we want highest first */
     return db->nr - da->nr;
index 8947baed5013bd514e59d84bf3c578bb359a730f..078da36b54337d77048d59e966e385457ed46f98 100644 (file)
@@ -298,7 +298,7 @@ static void calc_dist(real rcut, gmx_bool bPBC, int ePBC, matrix box, rvec x[],
                 {
                     nmin_j++;
                 }
-                else if (r2 > rcut2)
+                else
                 {
                     nmax_j++;
                 }
index 9dece7a6bdafea0d38be6bf0d04de1ee7d54bbb3..0b5ef29080927397907fd4c58f9a2b19bb6a65bd 100644 (file)
@@ -51,6 +51,7 @@
 #include "gromacs/math/functions.h"
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
+#include "gromacs/mdlib/broadcaststructs.h"
 #include "gromacs/mdrunutility/mdmodules.h"
 #include "gromacs/mdtypes/commrec.h"
 #include "gromacs/mdtypes/inputrec.h"
 #include "gromacs/utility/pleasecite.h"
 #include "gromacs/utility/smalloc.h"
 
-/* We use the same defines as in broadcaststructs.cpp here */
-#define  block_bc(cr,   d) gmx_bcast(     sizeof(d),     &(d), (cr))
-#define nblock_bc(cr, nr, d) gmx_bcast((nr)*sizeof((d)[0]), (d), (cr))
-#define   snew_bc(cr, d, nr) { if (!MASTER(cr)) {snew((d), (nr)); }}
 /* #define TAKETIME */
 /* #define DEBUG  */
 
index 4195da3eba601f570fb106dec36a3dc3057ed5de..3a7f4eaa2aa17928f29ac1cbcb7809be7e3400b6 100644 (file)
@@ -36,6 +36,7 @@
  */
 #include "gmxpre.h"
 
+#include <cassert>
 #include <cmath>
 #include <cstring>
 
@@ -119,6 +120,10 @@ static void average_residues(double f[], double **U, int uind,
     start = 0;
     av    = 0;
     m     = 0;
+    if (!f)
+    {
+        assert(U);
+    }
     for (i = 0; i < isize; i++)
     {
         av += w_rls[index[i]]*(f != NULL ? f[i] : U[i][uind]);
index e6205f23d4977f25c87ab136c8117c5d31382dba..2ae134932d0d1ab8d3811000994991a47b77dcbd 100644 (file)
@@ -44,6 +44,7 @@
 
 #include "config.h"
 
+#include <cassert>
 #include <cctype>
 #include <cmath>
 #include <cstdio>
@@ -2295,6 +2296,7 @@ void read_pull_xf(const char *fn, t_UmbrellaHeader * header,
 
     if (!bGetMinMax)
     {
+        assert(window);
         bins = opt->bins;
         min  = opt->min;
         max  = opt->max;
index 5b58fdd8d9aed72a82d84c2a798b04b19ba2a743..eb202583e6466272054afd05d7bf2ce10ffe6e72 100644 (file)
@@ -53,10 +53,10 @@ static const char *pp_pat[] = { "C", "N", "CA", "C", "N" };
 
 static int d_comp(const void *a, const void *b)
 {
-    t_dih *da, *db;
+    const t_dih *da, *db;
 
-    da = (t_dih *)a;
-    db = (t_dih *)b;
+    da = static_cast<const t_dih *>(a);
+    db = static_cast<const t_dih *>(b);
 
     if (da->ai[1] < db->ai[1])
     {
@@ -217,7 +217,7 @@ static void get_dih_props(t_xrama *xr, const t_idef *idef, int mult)
 
         key.ai[1] = ia[2];
         key.ai[2] = ia[3];
-        if ((dd = (t_dih *)bsearch(&key, xr->dih, xr->ndih, (size_t)sizeof(key), d_comp))
+        if ((dd = static_cast<t_dih *>(bsearch(&key, xr->dih, xr->ndih, (size_t)sizeof(key), d_comp)))
             != NULL)
         {
             dd->mult = idef->iparams[ft].pdihs.mult;
index dd9a9ab8f380153c9892d2e8af0bfb4034e4f121..4b7e7356caa98c0fc26f12c083aa6042775af745 100644 (file)
@@ -148,7 +148,7 @@ gmx_neutron_atomic_structurefactors_t *gmx_neutronstructurefactors_init(const ch
 
     fclose(fp);
 
-    return (gmx_neutron_atomic_structurefactors_t *) gnsf;
+    return gnsf;
 }
 
 gmx_sans_t *gmx_sans_init (const t_topology *top, gmx_neutron_atomic_structurefactors_t *gnsf)
@@ -186,7 +186,7 @@ gmx_sans_t *gmx_sans_init (const t_topology *top, gmx_neutron_atomic_structurefa
         }
     }
 
-    return (gmx_sans_t *) gsans;
+    return gsans;
 }
 
 gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram (
@@ -364,7 +364,7 @@ gmx_radial_distribution_histogram_t *calc_radial_distribution_histogram (
         pr->r[i] = (pr->binwidth*i+pr->binwidth*0.5);
     }
 
-    return (gmx_radial_distribution_histogram_t *) pr;
+    return pr;
 }
 
 gmx_static_structurefactor_t *convert_histogram_to_intensity_curve (gmx_radial_distribution_histogram_t *pr, double start_q, double end_q, double q_step)
@@ -405,5 +405,5 @@ gmx_static_structurefactor_t *convert_histogram_to_intensity_curve (gmx_radial_d
         }
     }
 
-    return (gmx_static_structurefactor_t *) sq;
+    return sq;
 }
index 94dee2656415fada44214041c1d451082457b8c1..d2660bc772e4f7e2b45b18c577aa8e742ada6f01 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.
@@ -41,6 +41,7 @@
 
 #include <string.h>
 
+#include <cassert>
 #include <cmath>
 
 #include "gromacs/gmxpreprocess/gpp_atomtype.h"
@@ -560,6 +561,7 @@ static void enter_function(t_params *p, t_functype ftype, int comb, real reppow,
         /* Type==-1 is used as a signal that this interaction is all-zero and should not be added. */
         if (!bNB && type >= 0)
         {
+            assert(il);
             nral  = NRAL(ftype);
             delta = nr*(nral+1);
             srenew(il->iatoms, il->nr+delta);
index ee7bf4cc3847401da96937dbf00b0187c6371e92..ed7ccdec712c785a685b0fb2d2190d1fcde2f1ee 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.
@@ -61,7 +61,7 @@
 #include "gromacs/utility/smalloc.h"
 
 #define DIHEDRAL_WAS_SET_IN_RTP 0
-static gmx_bool was_dihedral_set_in_rtp(t_param *dih)
+static gmx_bool was_dihedral_set_in_rtp(const t_param *dih)
 {
     return dih->c[MAXFORCEPARAM-1] == DIHEDRAL_WAS_SET_IN_RTP;
 }
@@ -70,11 +70,11 @@ typedef gmx_bool (*peq)(t_param *p1, t_param *p2);
 
 static int acomp(const void *a1, const void *a2)
 {
-    t_param *p1, *p2;
-    int      ac;
+    const t_param *p1, *p2;
+    int            ac;
 
-    p1 = (t_param *)a1;
-    p2 = (t_param *)a2;
+    p1 = static_cast<const t_param *>(a1);
+    p2 = static_cast<const t_param *>(a2);
     if ((ac = (p1->aj()-p2->aj())) != 0)
     {
         return ac;
@@ -91,11 +91,11 @@ static int acomp(const void *a1, const void *a2)
 
 static int pcomp(const void *a1, const void *a2)
 {
-    t_param *p1, *p2;
-    int      pc;
+    const t_param *p1, *p2;
+    int            pc;
 
-    p1 = (t_param *)a1;
-    p2 = (t_param *)a2;
+    p1 = static_cast<const t_param *>(a1);
+    p2 = static_cast<const t_param *>(a2);
     if ((pc = (p1->ai()-p2->ai())) != 0)
     {
         return pc;
@@ -108,11 +108,11 @@ static int pcomp(const void *a1, const void *a2)
 
 static int dcomp(const void *d1, const void *d2)
 {
-    t_param *p1, *p2;
-    int      dc;
+    const t_param *p1, *p2;
+    int            dc;
 
-    p1 = (t_param *)d1;
-    p2 = (t_param *)d2;
+    p1 = static_cast<const t_param *>(d1);
+    p2 = static_cast<const t_param *>(d2);
     /* First sort by J & K (the two central) atoms */
     if ((dc = (p1->aj()-p2->aj())) != 0)
     {
@@ -306,11 +306,11 @@ static int int_comp(const void *a, const void *b)
 
 static int idcomp(const void *a, const void *b)
 {
-    t_param *pa, *pb;
-    int      d;
+    const t_param *pa, *pb;
+    int            d;
 
-    pa = (t_param *)a;
-    pb = (t_param *)b;
+    pa = static_cast<const t_param *>(a);
+    pb = static_cast<const t_param *>(b);
     if ((d = (pa->a[0]-pb->a[0])) != 0)
     {
         return d;
index 913afe9233f84ec0d839aab8ae6cc8580c45642f..d93b55b74a7c00ed2fb083ae42acb0bce1a09e3f 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.
@@ -63,10 +63,15 @@ typedef struct {
     real       c[MAXFORCEPARAM]; /* Force parameters (eg. b0 = c[0])   */
     char       s[MAXSLEN];       /* A string (instead of parameters),    *
                                   * read from the .rtp file in pdb2gmx   */
+    const int &ai() const { return a[0]; }
     int   &ai() { return a[0]; }
+    const int &aj() const { return a[1]; }
     int   &aj() { return a[1]; }
+    const int &ak() const { return a[2]; }
     int   &ak() { return a[2]; }
+    const int &al() const { return a[3]; }
     int   &al() { return a[3]; }
+    const int &am() const { return a[4]; }
     int   &am() { return a[4]; }
 
     real      &c0() { return c[0]; }
index 61cb60f705c6dc55c160ba784872572e9c4655db..50dee9d5e0a558c77140bf1478ecfeef2c0b186f 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.
@@ -63,10 +63,10 @@ const int ncontrol[] = { -1, 3, 3, 3, 3, 4, 3, 1, 3, 3, 1, 1 };
 
 int compaddh(const void *a, const void *b)
 {
-    t_hackblock *ah, *bh;
+    const t_hackblock *ah, *bh;
 
-    ah = (t_hackblock *)a;
-    bh = (t_hackblock *)b;
+    ah = static_cast<const t_hackblock *>(a);
+    bh = static_cast<const t_hackblock *>(b);
     return gmx_strcasecmp(ah->name, bh->name);
 }
 
@@ -240,7 +240,7 @@ t_hackblock *search_h_db(int nh, t_hackblock ah[], char *key)
 
     ahkey.name = key;
 
-    result = (t_hackblock *)bsearch(&ahkey, ah, nh, (size_t)sizeof(ah[0]), compaddh);
+    result = static_cast<t_hackblock *>(bsearch(&ahkey, ah, nh, (size_t)sizeof(ah[0]), compaddh));
 
     return result;
 }
index 1753d190f50ee0efbf940b8771bfbb940e8fad0f..9943fe4cc24ae44cee7c8cda68b580e9968d1291 100644 (file)
@@ -843,10 +843,10 @@ static void at2bonds(t_params *psb, t_hackblock *hb,
 
 static int pcompar(const void *a, const void *b)
 {
-    t_param *pa, *pb;
-    int      d;
-    pa = (t_param *)a;
-    pb = (t_param *)b;
+    const t_param *pa, *pb;
+    int            d;
+    pa = static_cast<const t_param *>(a);
+    pb = static_cast<const t_param *>(b);
 
     d = pa->a[0] - pb->a[0];
     if (d == 0)
index 3e121c8078bbbf8c0cccbc72d7bcc652ad2f7f88..e262876d1abf65ea9c624ed8ba20ef7c599c24ba 100644 (file)
@@ -262,10 +262,10 @@ static void check_rtp(int nrtp, t_restp rtp[], char *libfn)
 
 static int comprtp(const void *a, const void *b)
 {
-    t_restp *ra, *rb;
+    const t_restp *ra, *rb;
 
-    ra = (t_restp *)a;
-    rb = (t_restp *)b;
+    ra = static_cast<const t_restp *>(a);
+    rb = static_cast<const t_restp *>(b);
 
     return gmx_strcasecmp(ra->resname, rb->resname);
 }
index 763b030ca6723951c398a47d7059f0b740ea4b16..7848a959ac53b5f473ea93535e89761fe68a66fc 100644 (file)
@@ -70,6 +70,7 @@
 #include "gromacs/imd/imdsocket.h"
 #include "gromacs/math/units.h"
 #include "gromacs/math/vec.h"
+#include "gromacs/mdlib/broadcaststructs.h"
 #include "gromacs/mdlib/groupcoord.h"
 #include "gromacs/mdlib/mdrun.h"
 #include "gromacs/mdlib/sighandler.h"
 /*! \brief IMD Protocol Version. */
 #define IMDVERSION 2
 
-/*! \brief Broadcast d to all nodes */
-#define  block_bc(cr, d) gmx_bcast(sizeof(d), &(d), (cr))
-
-/*! \brief Broadcast nr elements of d to all nodes */
-#define  nblock_bc(cr, nr, d) gmx_bcast((nr)*sizeof((d)[0]), (d), (cr))
-
 
 /*! \internal
  * \brief
index 03185f084316873609abe9187ec32a6e034729fe..a63915e096094722ab28b4c4cf9e93de1123e254 100644 (file)
@@ -1647,7 +1647,7 @@ L65:
         F77_FUNC(dgemv, DGEMV) ("T", n, &iwork[12], &c_b18, &v[v_offset], ldv, &workd[iwork[8]],
                                 &c__1, &c_b42, &workd[iwork[9]], &c__1);
     }
-    else if (*mode == 2)
+    else
     {
         F77_FUNC(dgemv, DGEMV) ("T", n, &iwork[12], &c_b18, &v[v_offset], ldv, &workd[iwork[10]
                                 ], &c__1, &c_b42, &workd[iwork[9]], &c__1);
@@ -4510,7 +4510,7 @@ L65:
         F77_FUNC(sgemv, SGEMV) ("T", n, &iwork[12], &c_b18, &v[v_offset], ldv, &workd[iwork[8]],
                                 &c__1, &c_b42, &workd[iwork[9]], &c__1);
     }
-    else if (*mode == 2)
+    else
     {
         F77_FUNC(sgemv, SGEMV) ("T", n, &iwork[12], &c_b18, &v[v_offset], ldv, &workd[iwork[10]
                                 ], &c__1, &c_b42, &workd[iwork[9]], &c__1);
index 0b3004b0693bf89a993a04483d7ee9aecc7ed3b0..a9513588b193c1be5e9abf799a2d628fb2187ac2 100644 (file)
@@ -121,6 +121,7 @@ F77_FUNC(dstebz,DSTEBZ)(const char *range,
     ulp = 2*GMX_DOUBLE_EPS;
     rtoli = ulp * 2.;
     nb = DSTEBZ_BLOCKSIZE;
+    // cppcheck-suppress knownConditionTrueFalse
     if (nb <= 1) {
        nb = 0;
     }
index 652f2cc539fab215868ba8b78db6c99de9048235..26ed314ae049e32e59764148afb1f4f48561ce3a 100644 (file)
@@ -121,6 +121,7 @@ F77_FUNC(sstebz,SSTEBZ)(const char *range,
     ulp = 2*GMX_FLOAT_EPS;
     rtoli = ulp * 2.;
     nb = DSTEBZ_BLOCKSIZE;
+    // cppcheck-suppress knownConditionTrueFalse
     if (nb <= 1) {
        nb = 0;
     }
index c33b16b3279d455d9855d00c62aaf0647a383aaf..876a8ea454208c73c2eda2c32855581bdec43c8f 100644 (file)
@@ -37,6 +37,8 @@
 /* This file is completely threadsafe - keep it that way! */
 #include "gmxpre.h"
 
+#include "broadcaststructs.h"
+
 #include <string.h>
 
 #include "gromacs/gmxlib/network.h"
 #include "gromacs/utility/fatalerror.h"
 #include "gromacs/utility/smalloc.h"
 
-#define   block_bc(cr,   d) gmx_bcast(     sizeof(d),     &(d), (cr))
-#define  nblock_bc(cr, nr, d) { gmx_bcast((nr)*sizeof((d)[0]), (d), (cr)); }
-#define    snew_bc(cr, d, nr) { if (!MASTER(cr)) {snew((d), (nr)); }}
-
-#if !GMX_DOUBLE
-static void nblock_abc(const t_commrec *cr, int numElements, real **v)
-{
-    if (!MASTER(cr))
-    {
-        snew(*v, numElements);
-    }
-    nblock_bc(cr, numElements, *v);
-}
-#endif
-
-static void nblock_abc(const t_commrec *cr, int numElements, double **v)
-{
-    if (!MASTER(cr))
-    {
-        snew(*v, numElements);
-    }
-    nblock_bc(cr, numElements, *v);
-}
-
-static void nblock_abc(const t_commrec *cr, int numElements, std::vector<double> *v)
-{
-    if (!MASTER(cr))
-    {
-        v->resize(numElements);
-    }
-    gmx_bcast(numElements*sizeof(double), v->data(), cr);
-}
-
 static void bc_cstring(const t_commrec *cr, char **s)
 {
     int size = 0;
diff --git a/src/gromacs/mdlib/broadcaststructs.h b/src/gromacs/mdlib/broadcaststructs.h
new file mode 100644 (file)
index 0000000..fa5503e
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * To help us fund GROMACS development, we humbly ask that you cite
+ * the research papers on the package. Check out http://www.gromacs.org.
+ */
+
+/*! \libinternal \file
+ *
+ * \brief Convenience wrappers for broadcasting structs.
+ *
+ * \author Mark Abraham <mark.j.abraham@gmail.com>
+ *
+ * \inlibraryapi
+ * \ingroup module_mdlib
+ */
+#ifndef GMX_MDLIB_BROADCASTSTRUCTS_H
+#define GMX_MDLIB_BROADCASTSTRUCTS_H
+
+#include <vector>
+
+#include "gromacs/gmxlib/network.h"
+#include "gromacs/mdtypes/commrec.h"
+#include "gromacs/utility/smalloc.h"
+
+//! Convenience wrapper for gmx_bcast of a single value.
+template <typename T>
+void block_bc(const t_commrec *cr, T &data)
+{
+    gmx_bcast(sizeof(T), static_cast<void *>(&data), cr);
+}
+//! Convenience wrapper for gmx_bcast of a C-style array.
+template <typename T>
+void nblock_bc(const t_commrec *cr, int numElements, T *data)
+{
+    gmx_bcast(numElements * sizeof(T), static_cast<void *>(data), cr);
+}
+//! Convenience wrapper for allocation with snew of vectors that need allocation on non-master ranks.
+template <typename T>
+void snew_bc(const t_commrec *cr, T * &data, int numElements)
+{
+    if (!MASTER(cr))
+    {
+        snew(data, numElements);
+    }
+}
+//! Convenience wrapper for gmx_bcast of a C-style array which needs allocation on non-master ranks.
+template <typename T>
+static void nblock_abc(const t_commrec *cr, int numElements, T **v)
+{
+    snew_bc(cr, v, numElements);
+    nblock_bc(cr, numElements, *v);
+}
+//! Convenience wrapper for gmx_bcast of a std::vector which needs resizing on non-master ranks.
+template <typename T>
+static void nblock_abc(const t_commrec *cr, int numElements, std::vector<T> *v)
+{
+    if (!MASTER(cr))
+    {
+        v->resize(numElements);
+    }
+    gmx_bcast(numElements*sizeof(T), v->data(), cr);
+}
+
+#endif
index 5c27505942141b4ba6e6a117a3d290186e71b1aa..ae662ec467d8eb5e97ba585f84d3fa04ec830cc2 100644 (file)
@@ -1545,10 +1545,6 @@ gmx_bool can_use_allvsall(const t_inputrec *ir, gmx_bool bPrintNote, t_commrec *
 
         if (bPrintNote)
         {
-            if (MASTER(cr))
-            {
-                fprintf(stderr, "\n%s\n", note);
-            }
             if (fp != NULL)
             {
                 fprintf(fp, "\n%s\n", note);
index 644bb05a8b0e1deab070cc41afc4917a02b1dc0f..f4aa5a919cebca88cfc268d40b38d26d341a7b2c 100644 (file)
@@ -128,6 +128,7 @@ static void pick_module_nthreads(const gmx::MDLogger &mdlog, int m,
     {
         sscanf(env, "%d", &nth);
 
+        // cppcheck-suppress knownConditionTrueFalse
         if (!bOMP)
         {
             gmx_warning("%s=%d is set, but %s is compiled without OpenMP!",
index a7d886b73b29200f338adbb9530c4946b88d0d2d..ee0f4e83c0729bd4192148a4d49b588765ae67f4 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.
@@ -42,6 +42,8 @@
 #include <math.h>
 #include <string.h>
 
+#include <cassert>
+
 #include "gromacs/fileio/enxio.h"
 #include "gromacs/mdlib/mdebin.h"
 #include "gromacs/mdtypes/energyhistory.h"
@@ -67,12 +69,12 @@ static void mde_delta_h_init(t_mde_delta_h *dh, int nbins,
 
     dh->type       = type;
     dh->derivative = derivative;
-    dh->lambda     = lambda;
     dh->nlambda    = nlambda;
 
     snew(dh->lambda, nlambda);
     for (i = 0; i < nlambda; i++)
     {
+        assert(lambda);
         dh->lambda[i] = lambda[i];
     }
 
index 846a281037a762a79ffd16910a90d619da019aba..62f5cc96a8f5c4e531c832c961a69754d83d721e 100644 (file)
                 {
                     real skipmask_rvdw;
 
-                    skipmask_rvdw = (rsq < rvdw2);
+                    skipmask_rvdw = (rsq < rvdw2) ? 1.0 : 0.0;
                     frLJ         *= skipmask_rvdw;
 #ifdef CALC_ENERGIES
                     VLJ    *= skipmask_rvdw;
index 3a4730c8591d8633ce64df2367dbddf88c54a009..d19652adeccfddca285dad5308d8b6f73b745269 100644 (file)
@@ -113,6 +113,7 @@ class OptionValueStoreVector : public IOptionValueStore<T>
 
 // Specialization that works around std::vector<bool> specialities.
 template <>
+// cppcheck-suppress noConstructor
 class OptionValueStoreVector<bool> : public IOptionValueStore<bool>
 {
     public:
index 059ff4b3486476d92ed3d8473f59ff063971052c..0639890a0db148b09f437eda7c01997ed4340c81 100644 (file)
@@ -518,7 +518,7 @@ gmx_calc_comg_blocka(const gmx_mtop_t *top, rvec x[], const t_blocka *block,
                      bool bMass, rvec xout[])
 {
     /* TODO: It would probably be better to do this without the type cast */
-    gmx_calc_comg_block(top, x, (t_block *)block, block->a, bMass, xout);
+    gmx_calc_comg_block(top, x, reinterpret_cast<const t_block *>(block), block->a, bMass, xout);
 }
 
 /*!
@@ -544,5 +544,5 @@ gmx_calc_comg_f_blocka(const gmx_mtop_t *top, rvec f[], const t_blocka *block,
                        bool bMass, rvec fout[])
 {
     /* TODO: It would probably be better to do this without the type cast */
-    gmx_calc_comg_f_block(top, f, (t_block *)block, block->a, bMass, fout);
+    gmx_calc_comg_f_block(top, f, reinterpret_cast<const t_block *>(block), block->a, bMass, fout);
 }
index 8aa31e40f14ad864a7b392e21e6ca446186fd434..2c81620370e427ae2ddb8fdd780b32dcd51b70a4 100644 (file)
@@ -137,6 +137,7 @@ SelectionTreeElement::SelectionTreeElement(e_selelem_t              type,
                                            const SelectionLocation &location)
     : location_(location)
 {
+    // cppcheck-suppress useInitializationList
     this->type       = type;
     this->flags      = (type != SEL_ROOT) ? SEL_ALLOCVAL : 0;
     if (type == SEL_BOOLEAN)
index fb669014717b64f3e525c89742df3be626b78597..503e93bd14fa41e8606fcbe9abf13e2a3ad50a00 100644 (file)
@@ -166,9 +166,9 @@ simdSuggested(const CpuInfo &c)
                 {
                     suggested = SimdType::Ibm_Vsx;
                 }
-                else if (c.feature(CpuInfo::Feature::Ibm_Vsx))
+                else if (c.feature(CpuInfo::Feature::Ibm_Vmx))
                 {
-                    suggested = SimdType::Ibm_Vsx;
+                    suggested = SimdType::Ibm_Vmx;
                 }
                 else if (c.feature(CpuInfo::Feature::Ibm_Qpx))
                 {
index f1300f2f34bedbb197f7f935c10285cc48dde8a4..ace7395591bca39e5118ae29a4b5d8fc76f791ba 100644 (file)
@@ -847,7 +847,6 @@ int find_group(const char *s, int ngrps, char **grpname)
     n         = strlen(s);
     aa        = -1;
     /* first look for whole name match */
-    if (aa == -1)
     {
         for (i = 0; i < ngrps; i++)
         {
index 235863d7f4c30b2be1a877b68a8e5c9fb8d181d8..5d3c5c30c5bb3f9517a765c9707de93ff946c870 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.
@@ -57,6 +57,9 @@ static char *trim_string(const char *s, char *out, int maxlen)
  * Returns a pointer to a static area which contains a copy
  * of s without leading or trailing spaces. Strings are
  * truncated to BUFSIZE positions.
+ *
+ * TODO This partially duplicates code in trim(), but perhaps
+ * replacing symtab with a std::map is a better fix.
  */
 {
     int len, i;
@@ -67,7 +70,7 @@ static char *trim_string(const char *s, char *out, int maxlen)
                   s, strlen(s), maxlen-1);
     }
 
-    for (; (*s) && ((*s) == ' '); s++)
+    for (; (*s) == ' '; s++)
     {
         ;
     }
index 050394cad21d1414062371d17d23364f1cbd6a1d..8d31b68d9feda6b4e3539481823c72d2f5f3a20c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, 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.
@@ -129,7 +129,7 @@ static void MBCallback(t_x11 * /*x11*/, int dlg_mess, int /*item_id*/,
 {
     t_gmx *gmx;
 
-    gmx = (t_gmx *)data;
+    gmx = static_cast<t_gmx *>(data);
     if (dlg_mess == DLG_EXIT)
     {
         hide_mb(gmx);
@@ -155,7 +155,7 @@ static void QuitCB(t_x11 *x11, int dlg_mess, int /*item_id*/,
                    char *set, void *data)
 {
     t_gmx  *gmx;
-    gmx = (t_gmx *)data;
+    gmx = static_cast<t_gmx *>(data);
 
     hide_mb(gmx);
     if (dlg_mess == DLG_EXIT)
@@ -215,7 +215,7 @@ static void ExportCB(t_x11 *x11, int dlg_mess, int item_id,
     t_gmx     *gmx;
     t_dlg     *dlg;
 
-    gmx = (t_gmx *)data;
+    gmx = static_cast<t_gmx *>(data);
     dlg = gmx->dlgs[edExport];
     switch (dlg_mess)
     {
@@ -278,7 +278,7 @@ static void BondsCB(t_x11 *x11, int dlg_mess, int item_id,
     t_gmx     *gmx;
     char      *endptr;
 
-    gmx = (t_gmx *)data;
+    gmx = static_cast<t_gmx *>(data);
     if (ebond == -1)
     {
         ebond = gmx->man->molw->bond_type;
index d9d43e72858b70652205fa5c6e008ba6b6f629cc..5a99f93191d5995074754f122fe049c90e9e6cbf 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.
@@ -500,7 +500,7 @@ static bool TitleCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data)
 {
     t_windata *wd;
 
-    wd = (t_windata *)data;
+    wd = static_cast<t_windata *>(data);
     switch (event->type)
     {
         case Expose:
@@ -525,7 +525,7 @@ static bool ManCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data)
     t_manager *man;
     int        width, height;
 
-    man = (t_manager *)data;
+    man = static_cast<t_manager *>(data);
     switch (event->type)
     {
         case ConfigureNotify:
index d2f27ef9d3f9b609d1853058ed92ebcd5d1e3488..f06896d2c94a0b00d99bee01ff2ac61c8cb45d84 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
  * Copyright (c) 2001-2013, 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.
@@ -61,7 +61,7 @@ static bool MWCallBack(t_x11 *x11, XEvent *event, Window /*w*/, void *data)
     Window    To;
     XEvent    letter;
 
-    mw                          = (t_molwin *)data;
+    mw                          = static_cast<t_molwin *>(data);
     To                          = mw->wd.Parent;
     letter.type                 = ClientMessage;
     letter.xclient.display      = x11->disp;
@@ -284,11 +284,11 @@ static void draw_bond(Display *disp, Window w, GC gc,
 
 int compare_obj(const void *a, const void *b)
 {
-    t_object *oa, *ob;
-    real      z;
+    const t_object *oa, *ob;
+    real            z;
 
-    oa = (t_object *)a;
-    ob = (t_object *)b;
+    oa = static_cast<const t_object *>(a);
+    ob = static_cast<const t_object *>(b);
 
     z = oa->z-ob->z;
 
index 0500bafe8b52fdf9944b7d0cfd3c1bf8139c1faf..5bd98865a0e66d1de2b5de36bd13e2f969304217 100644 (file)
@@ -105,7 +105,17 @@ if (CPPCHECK_EXECUTABLE AND UNIX)
         --suppress=passedByValue:src/gromacs/simd/tests/*
         --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/
+        --suppress=unusedStructMember:src/gromacs/onlinehelp/tests/helpmanager.cpp
+        --suppress=unusedStructMember:src/gromacs/commandline/cmdlinehelpmodule.cpp
+        --suppress=unusedStructMember:src/gromacs/selection/selhelp.cpp
+        --suppress=passedByValue # See comment below
         )
+        # Passing non-trivial objects by value is rarely a problem for
+        # GROMACS in performance-sensitive code, and shouldn't be
+        # enforced for types that are intended to be used like value
+        # types (e.g. SIMD wrapper types, ArrayRef) , nor for
+        # move-enabled types. cppcheck isn't sensitive to these
+        # subtleties yet.
 
     # This list will hold the list of all files with cppcheck errors
     # (one per input file)