# 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'
}
std::find(xvgFormats.begin(), xvgFormats.end(), std::string(select));
if (i != xvgFormats.end())
{
- return i - xvgFormats.begin();
+ return std::distance(xvgFormats.begin(), i);
}
else
{
#include <stdlib.h>
#include <string.h>
+#include <cassert>
+
#include <algorithm>
#include <string>
}
}
-/*! \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,
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];
#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
* 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.
}
}
}
- data = (t_complex *)out_data;
+ data = static_cast<t_complex *>(out_data);
/* y real-to-complex FFTs */
for (i = 0; i < nx; i++)
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 */
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)
fr->ener = NULL;
/*fr->d_alloc=0;*/
- fr->ener = NULL;
-
/*fr->ndisre=0;*/
fr->nblock = 0;
return FALSE;
}
*file_version = enx_version;
+ // cppcheck-suppress redundantPointerOp
if (!gmx_fio_do_int(ef->fio, *file_version))
{
*bOK = FALSE;
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;
gmx_fio_do_real(fio, ir->shake_tol);
if (file_version < 54)
{
+ // cppcheck-suppress redundantPointerOp
gmx_fio_do_real(fio, *fudgeQQ);
}
*
* 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.
#include "xvgr.h"
+#include <cassert>
#include <cctype>
#include <cstring>
{
if (*ny - 1 > legend_nalloc)
{
+ assert(legend);
srenew(*legend, *ny-1);
for (set = legend_nalloc; set < *ny-1; set++)
{
/*
* 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.
}
return iMin;
}
-
- else if (direction < 0)
+ else
{
while (iMax-iMin > 1)
{
}
}
return iMin-1;
-
- } /*end -ifelse direction*/
- return -1;
+ }
}
}
}
}
- else if (direction < 0)
+ else
{
for (i = stopindx; i >= startindx; i--)
{
}
}
- else
- {
- gmx_fatal(FARGS, "Startindex=stopindex=%d\n", startindx);
- }
-
return -1;
}
*/
#include "gmxpre.h"
+#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
}
else
{
+ assert(sy);
ymin = sy[g][0][0];
ymax = sy[g][0][0];
for (s = 0; s < nsetspergraph; s++)
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)
{
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;
{
nmin_j++;
}
- else if (r2 > rcut2)
+ else
{
nmax_j++;
}
#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 */
*/
#include "gmxpre.h"
+#include <cassert>
#include <cmath>
#include <cstring>
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]);
#include "config.h"
+#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
if (!bGetMinMax)
{
+ assert(window);
bins = opt->bins;
min = opt->min;
max = opt->max;
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])
{
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;
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)
}
}
- return (gmx_sans_t *) gsans;
+ return gsans;
}
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)
}
}
- return (gmx_static_structurefactor_t *) sq;
+ return sq;
}
*
* 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.
#include <string.h>
+#include <cassert>
#include <cmath>
#include "gromacs/gmxpreprocess/gpp_atomtype.h"
/* 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);
*
* 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.
#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;
}
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;
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;
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)
{
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;
*
* 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.
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]; }
*
* 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.
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);
}
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;
}
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)
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);
}
#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
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);
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);
ulp = 2*GMX_DOUBLE_EPS;
rtoli = ulp * 2.;
nb = DSTEBZ_BLOCKSIZE;
+ // cppcheck-suppress knownConditionTrueFalse
if (nb <= 1) {
nb = 0;
}
ulp = 2*GMX_FLOAT_EPS;
rtoli = ulp * 2.;
nb = DSTEBZ_BLOCKSIZE;
+ // cppcheck-suppress knownConditionTrueFalse
if (nb <= 1) {
nb = 0;
}
/* 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;
--- /dev/null
+/*
+ * 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
if (bPrintNote)
{
- if (MASTER(cr))
- {
- fprintf(stderr, "\n%s\n", note);
- }
if (fp != NULL)
{
fprintf(fp, "\n%s\n", note);
{
sscanf(env, "%d", &nth);
+ // cppcheck-suppress knownConditionTrueFalse
if (!bOMP)
{
gmx_warning("%s=%d is set, but %s is compiled without OpenMP!",
*
* 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.
#include <math.h>
#include <string.h>
+#include <cassert>
+
#include "gromacs/fileio/enxio.h"
#include "gromacs/mdlib/mdebin.h"
#include "gromacs/mdtypes/energyhistory.h"
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];
}
{
real skipmask_rvdw;
- skipmask_rvdw = (rsq < rvdw2);
+ skipmask_rvdw = (rsq < rvdw2) ? 1.0 : 0.0;
frLJ *= skipmask_rvdw;
#ifdef CALC_ENERGIES
VLJ *= skipmask_rvdw;
// Specialization that works around std::vector<bool> specialities.
template <>
+// cppcheck-suppress noConstructor
class OptionValueStoreVector<bool> : public IOptionValueStore<bool>
{
public:
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);
}
/*!
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);
}
const SelectionLocation &location)
: location_(location)
{
+ // cppcheck-suppress useInitializationList
this->type = type;
this->flags = (type != SEL_ROOT) ? SEL_ALLOCVAL : 0;
if (type == SEL_BOOLEAN)
{
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))
{
n = strlen(s);
aa = -1;
/* first look for whole name match */
- if (aa == -1)
{
for (i = 0; i < ngrps; i++)
{
*
* 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.
* 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;
s, strlen(s), maxlen-1);
}
- for (; (*s) && ((*s) == ' '); s++)
+ for (; (*s) == ' '; s++)
{
;
}
*
* 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.
{
t_gmx *gmx;
- gmx = (t_gmx *)data;
+ gmx = static_cast<t_gmx *>(data);
if (dlg_mess == DLG_EXIT)
{
hide_mb(gmx);
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)
t_gmx *gmx;
t_dlg *dlg;
- gmx = (t_gmx *)data;
+ gmx = static_cast<t_gmx *>(data);
dlg = gmx->dlgs[edExport];
switch (dlg_mess)
{
t_gmx *gmx;
char *endptr;
- gmx = (t_gmx *)data;
+ gmx = static_cast<t_gmx *>(data);
if (ebond == -1)
{
ebond = gmx->man->molw->bond_type;
*
* 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.
{
t_windata *wd;
- wd = (t_windata *)data;
+ wd = static_cast<t_windata *>(data);
switch (event->type)
{
case Expose:
t_manager *man;
int width, height;
- man = (t_manager *)data;
+ man = static_cast<t_manager *>(data);
switch (event->type)
{
case ConfigureNotify:
*
* 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.
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;
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;
--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)