#else
/* Define storage for little-endian or both types of CPUs. */
md5_word_t xbuf[16];
- /* cppcheck-suppress unassignedVariable */
const md5_word_t *X;
#endif
/* Keep the curr_edi pointer for the case that the next group is empty: */
last_edi = curr_edi;
/* Let's prepare to read in the next edi data set: */
+ /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
curr_edi = edi_read;
}
if (edi_nr == 0)
{
int i;
- for (i = 0; (src[i] != '\0') && (i < maxlen - 1); i++)
+ for (i = 0; (i < maxlen - 1) && (src[i] != '\0'); i++)
{
if ((src[i] == ' ') || (src[i] == '\t'))
{
{
int i;
- for (i = 0; (src[i] != '\0') && (i < maxlen - 1); i++)
+ for (i = 0; (i < maxlen - 1) && (src[i] != '\0'); i++)
{
if (src[i] == '_')
{
#else
/* Define storage for little-endian or both types of CPUs. */
md5_word_t xbuf[16];
- /* cppcheck-suppress unassignedVariable */
const md5_word_t *X;
#endif
if (bCPT)
{
(*nchkpt)++;
- bCPT = FALSE;
}
debug_gmx();
if (bLastStep && step_rel == ir->nsteps &&
imaj = (int)imaj64;
imin = (int)imin64;
ret = xdr_int(xdrs, &imaj);
- ret = xdr_int(xdrs, &imin);
+ ret |= xdr_int(xdrs, &imin);
*i = (((gmx_int64_t)imaj << 32) | ((gmx_int64_t)imin & two_p32_m1));
idef->il[i].iatoms[j] = niatoms[j];
}
idef->il[i].nr = nnr;
+ /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(niatoms);
}
}
str += sprintf(str, "dH/dl");
if (strlen(lv->lc->names[lv->dhdl]) > 0)
{
- str += sprintf(str, " (%s)", lv->lc->names[lv->dhdl]);
+ sprintf(str, " (%s)", lv->lc->names[lv->dhdl]);
}
}
}
{
if (debug)
{
- fprintf(debug, "{%d %d}", *i1+bFW ? dx : dy, *i2+bFW ? dy : dx );
+ fprintf(debug, "{%d %d}", *i1 + (bFW ? dx : dy), *i2 + (bFW ? dy : dx) );
}
if (bFW)
{
#include <config.h>
#endif
+#include <assert.h>
#include <stdlib.h>
#include "gromacs/commandline/pargs.h"
xshfr[i] = 0.0;
}
}
-
+ assert(time != NULL);
if (nfr == 0)
gmx_bool *bPhbres, bDoAccSurf;
real t;
int i, j, natoms, nframe = 0;
- matrix box;
+ matrix box = {{0}};
int gnx;
char *grpnm, *ss_str;
atom_id *index;
nset = 0;
timestep = 0.0;
snew(fnms, argc);
- nfile = 0;
lastfilestep = 0;
laststep = startstep = 0;
{
int i;
- if (ISDON(datable[id]) || !datable)
+ if (!datable || ISDON(datable[id]))
{
if (ddd->dptr[id] == NOTSET) /* New donor */
{
static void normalizeACF(real *ct, real *gt, int nhb, int len)
{
- real ct_fac, gt_fac;
+ real ct_fac, gt_fac = 0;
int i;
/* Xu and Berne use the same normalization constant */
ct_fac = 1.0/ct[0];
- gt_fac = (nhb == 0) ? 0 : 1.0/(real)nhb;
+ if (nhb != 0)
+ {
+ gt_fac = 1.0/(real)nhb;
+ }
printf("Normalization for c(t) = %g for gh(t) = %g\n", ct_fac, gt_fac);
for (i = 0; i < len; i++)
{
t_matrix mat;
int id, ia, hh, x, y;
+ mat.flags = mat.y0 = 0;
if ((nframes > 0) && (hb->nrhb > 0))
{
fprintf(stderr, "Using following groups: \n");
for (i = 0; i < ngrps; i++)
{
- fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %u\n",
+ fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %d\n",
groups[i], *(top->atoms.atomname[a[index[i]]]), a[index[i]]);
}
fprintf(stderr, "\n");
printf("\n");
}
- EigvecFile = NULL;
EigvecFile = opt2fn("-f", NFILE, fnm);
/*read eigenvectors from eigvec.trr*/
int **nmat, **totnmat;
real *mean_n;
int *tot_n;
- matrix box;
+ matrix box = {{0}};
output_env_t oenv;
gmx_rmpbc_t gpbc = NULL;
fprintf(stderr, "Using following groups: \n");
for (i = 0; i < ngrps; i++)
{
- fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %u\n",
+ fprintf(stderr, "Groupname: %s First atomname: %s First atomnr %d\n",
groups[i], *(top->atoms.atomname[a[index[i]]]), a[index[i]]);
}
fprintf(stderr, "\n");
int ePBC;
t_iatom *iatom = NULL;
- matrix box;
+ matrix box = {{0}};
rvec *x, *xp, *xm = NULL, **mat_x = NULL, **mat_x2, *mat_x2_j = NULL, vec1,
vec2;
t_trxstatus *status;
/* Only mention settings if they were modified: */
bRefinedCoul = !gmx_within_tol(info->rcoulomb[k_win], info->rcoulomb[0], GMX_REAL_EPS);
- bRefinedCoul = !gmx_within_tol(info->rcoulomb[k_win], info->rcoulomb[0], GMX_REAL_EPS);
bRefinedVdW = !gmx_within_tol(info->rvdw[k_win], info->rvdw[0], GMX_REAL_EPS);
bRefinedGrid = !(info->nkx[k_win] == info->nkx[0] &&
info->nky[k_win] == info->nky[0] &&
#include <config.h>
#endif
+#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
srenew(sbox, nalloc);
srenew(sx, nalloc);
}
+ assert(time != NULL); assert(sbox != NULL);
time[nfr] = t;
copy_mat(box, sbox[nfr]);
sfree(mat[i].map);
mat[i].nmap = nmap;
mat[i].map = map;
- if (mat2 && (strcmp(mat[i].title, mat2[i].title) != 0))
+ if (strcmp(mat[i].title, mat2[i].title) != 0)
{
sprintf(mat[i].title+strlen(mat[i].title), " / %s", mat2[i].title);
}
- if (mat2 && (strcmp(mat[i].legend, mat2[i].legend) != 0))
+ if (strcmp(mat[i].legend, mat2[i].legend) != 0)
{
sprintf(mat[i].legend+strlen(mat[i].legend), " / %s", mat2[i].legend);
}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2013,2014, 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.
{
nrerror("allocation failure in rvector()", TRUE);
}
+ /* cppcheck-suppress memleak
+ * free_vector does the same vector arithmetic */
return v-nl;
}
{
nrerror("allocation failure in ivector()", TRUE);
}
+ /* cppcheck-suppress memleak
+ * free_vector does the same vector arithmetic */
return v-nl;
}
{
copy_rvec (fr->x[index[i]], pos[i].x);
}
-
- positions = (reduced_atom_t *)pos;
}
{
if (dtc == xdr_datatype_double)
{
+ /* cppcheck-suppress invalidPointerCast
+ * Only executed if real is anyhow double */
vd = (double *)vp;
}
else
}
for (i = 0; i < n; i++)
{
- reti = 0;
vr = v[i];
reti = do_cpte_reals_low(xd, cptp, ecpt, sflags, n, NULL, &(v[i]), NULL, ecprREAL);
if (list && reti == 0)
{
enerhist->ener_sum_sim[i] = enerhist->ener_sum[i];
}
- fflags |= (1<<eenhENERGY_SUM_SIM);
}
if ( (fflags & (1<<eenhENERGY_NSUM)) &&
{
/* Assume we have an old file format and copy nsum to nsteps */
enerhist->nsteps = enerhist->nsum;
- fflags |= (1<<eenhENERGY_NSTEPS);
}
if ( (fflags & (1<<eenhENERGY_NSUM_SIM)) &&
!(fflags & (1<<eenhENERGY_NSTEPS_SIM)))
{
/* Assume we have an old file format and copy nsum to nsteps */
enerhist->nsteps_sim = enerhist->nsum_sim;
- fflags |= (1<<eenhENERGY_NSTEPS_SIM);
}
return ret;
for (i = 0; i <= block->nr; i++)
{
(void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "%s->index[%d]=%u\n",
+ (void) fprintf(fp, "%s->index[%d]=%d\n",
title, bShowNumbers ? i : -1, block->index[i]);
}
for (i = 0; i < block->nra; i++)
{
(void) pr_indent(fp, indent+INDENT);
- (void) fprintf(fp, "%s->a[%d]=%u\n",
+ (void) fprintf(fp, "%s->a[%d]=%d\n",
title, bShowNumbers ? i : -1, block->a[i]);
}
}
(void) fprintf(fp, "\n");
size = pr_indent(fp, indent+INDENT);
}
- size += fprintf(fp, "%u", block->a[j]);
+ size += fprintf(fp, "%d", block->a[j]);
}
(void) fprintf(fp, "}\n");
start = end;
add_at(&att, &natt, &prop[a], nmol);
}
+ /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(vsite_m);
sfree(prop);
}
{
fprintf(debug,
"Something VERY strange is going on in rm2par (gen_ad.c)\n"
- "a[0] %u a[1] %u a[2] %u a[3] %u\n",
+ "a[0] %d a[1] %d a[2] %d a[3] %d\n",
p[i].a[0], p[i].a[1], p[i].a[2], p[i].a[3]);
}
strcpy(p[i].s, "");
if (seed == 0)
{
seed = gmx_rng_make_seed();
- fprintf(stderr, "Using random seed %d for generating velocities\n", seed);
+ fprintf(stderr, "Using random seed %u for generating velocities\n", seed);
}
rng = gmx_rng_init(seed);
{
if (debug)
{
- fprintf(debug, " [%u -> %u]", params->param[i].a[j],
+ fprintf(debug, " [%d -> %d]", params->param[i].a[j],
params->param[i].a[j]-add_shift);
}
params->param[i].a[j] = params->param[i].a[j]-add_shift;
{
if (debug)
{
- fprintf(debug, " [%u -> %d]", params->param[i].a[j],
+ fprintf(debug, " [%d -> %d]", params->param[i].a[j],
o2n[params->param[i].a[j]]);
}
params->param[i].a[j] = o2n[params->param[i].a[j]];
sfree(ga->atomnumber);
ga->nr = 0;
sfree(ga);
- ga = NULL;
}
static int search_atomtypes(gpp_atomtype_t ga, int *n, int typelist[],
void make_IMD_group(t_IMD *IMDgroup, char *IMDgname, t_blocka *grps, char **gnames)
{
- int ig = -1, i;
+ int ig, i;
ig = search_string(IMDgname, grps->nr, gnames);
moltp = NOTSET;
for (j = 0; (j < nrmoltypes) && (moltp == NOTSET); j++)
{
- if (strcmp(*(atoms->resinfo[atoms->atom[i].resind].name),
- moltypes[j].name) == 0)
+ /* cppcheck-suppress nullPointer
+ * moltypes is guaranteed to be allocated because otherwise
+ * nrmoltypes is 0. */
+ if (strcmp(*(atoms->resinfo[atoms->atom[i].resind].name), moltypes[j].name) == 0)
{
moltp = j;
}
last++;
}
}
+ /* cppcheck-suppress uninitvar Fixed in cppcheck 1.65 */
sfree(bRemoveHarm);
fprintf(stderr, "Converted %d out of %d %s to morse bonds for mol %d\n",
nrharm-last, nrharm, interaction_function[bb].name, i);
j = 0;
while (j < molt->ilist[i].nr)
{
- bexcl = FALSE;
a1 = molt->ilist[i].iatoms[j+1];
a2 = molt->ilist[i].iatoms[j+2];
bexcl = ((bQMMM[a1] && bQMMM[a2]) ||
extern int imdsock_bind(IMDSocket *sock, int port)
{
- int ret = -1;
+ int ret;
#ifdef GMX_IMD
/* Try to bind to address and port ...*/
ret = bind(sock->sockfd, (struct sockaddr *) &sock->address, sizeof(sock->address));
+#else
+ ret = -1;
#endif
if (ret)
extern int imd_sock_listen(IMDSocket *sock)
{
- int ret = -1;
+ int ret;
#ifdef GMX_IMD
/* Try to set to listening state */
ret = listen(sock->sockfd, MAXIMDCONNECTIONS);
+#else
+ ret = -1;
#endif
if (ret)
extern IMDSocket* imdsock_accept(IMDSocket *sock)
{
- int ret = -1;
+ int ret;
#ifdef GMX_IMD
socklen_t length;
extern int imdsock_getport(IMDSocket *sock, int *port)
{
- int ret = -1;
+ int ret;
#ifdef GMX_IMD
struct sockaddr_in sin;
socklen_t len;
gmx_bool gmx_isnan(real x)
{
- /* cppcheck-suppress duplicateExpression */
return x != x;
}
j, constr->nblocks, ncons);
for (i = 0; (i < ncons); i++)
{
- fprintf(stderr, "i: %5d sb[i].blocknr: %5u\n", i, sb[i].blocknr);
+ fprintf(stderr, "i: %5d sb[i].blocknr: %5d\n", i, sb[i].blocknr);
}
for (j = 0; (j <= constr->nblocks); j++)
{
snew(grid_r, 2*dd->nnodes);
}
- dd_gather(dd, 2*sizeof(rvec), grid_s[0], DDMASTER(dd) ? grid_r[0] : NULL);
+ dd_gather(dd, 2*sizeof(rvec), grid_s, DDMASTER(dd) ? grid_r : NULL);
if (DDMASTER(dd))
{
if (Nsep > 1)
{
/* and add the closing parenthesis */
- str += sprintf(str, ")");
+ sprintf(str, ")");
}
}
}
stepsize = 1.0/fnorm;
- converged = FALSE;
/* Start the loop over BFGS steps.
* Each successful step is counted, and we continue until
if (devinfo->prop.major >= 3)
{
/* Default kernel on sm 3.x 48/16 kB Shared/L1 */
- stat = cudaFuncSetCacheConfig(nb_kfunc_ener_prune_ptr[i][j], cudaFuncCachePreferShared);
- stat = cudaFuncSetCacheConfig(nb_kfunc_ener_noprune_ptr[i][j], cudaFuncCachePreferShared);
- stat = cudaFuncSetCacheConfig(nb_kfunc_noener_prune_ptr[i][j], cudaFuncCachePreferShared);
+ cudaFuncSetCacheConfig(nb_kfunc_ener_prune_ptr[i][j], cudaFuncCachePreferShared);
+ cudaFuncSetCacheConfig(nb_kfunc_ener_noprune_ptr[i][j], cudaFuncCachePreferShared);
+ cudaFuncSetCacheConfig(nb_kfunc_noener_prune_ptr[i][j], cudaFuncCachePreferShared);
stat = cudaFuncSetCacheConfig(nb_kfunc_noener_noprune_ptr[i][j], cudaFuncCachePreferShared);
}
else
{
/* On Fermi prefer L1 gives 2% higher performance */
/* Default kernel on sm_2.x 16/48 kB Shared/L1 */
- stat = cudaFuncSetCacheConfig(nb_kfunc_ener_prune_ptr[i][j], cudaFuncCachePreferL1);
- stat = cudaFuncSetCacheConfig(nb_kfunc_ener_noprune_ptr[i][j], cudaFuncCachePreferL1);
- stat = cudaFuncSetCacheConfig(nb_kfunc_noener_prune_ptr[i][j], cudaFuncCachePreferL1);
+ cudaFuncSetCacheConfig(nb_kfunc_ener_prune_ptr[i][j], cudaFuncCachePreferL1);
+ cudaFuncSetCacheConfig(nb_kfunc_ener_noprune_ptr[i][j], cudaFuncCachePreferL1);
+ cudaFuncSetCacheConfig(nb_kfunc_noener_prune_ptr[i][j], cudaFuncCachePreferL1);
stat = cudaFuncSetCacheConfig(nb_kfunc_noener_noprune_ptr[i][j], cudaFuncCachePreferL1);
}
CU_RET_ERR(stat, "cudaFuncSetCacheConfig failed");
#undef HALF_LJ
#undef CALC_COULOMB
}
- /* cppcheck-suppress duplicateBranch */
else if (do_coul)
{
#define CALC_COULOMB
#undef HALF_LJ
#undef CALC_COULOMB
}
- /* cppcheck-suppress duplicateBranch */
else if (do_coul)
{
#define CALC_COULOMB
int cxy_start, int cxy_end,
int *sort_work)
{
- int cxy;
- int cx, cy, cz = -1, c = -1, ncz;
- int na, ash, na_c, ind, a;
- int subdiv_z, sub_z, na_z, ash_z;
- int subdiv_y, sub_y, na_y, ash_y;
- int subdiv_x, sub_x, na_x, ash_x;
+ int cxy;
+ int cx, cy, cz = -1, c = -1, ncz;
+ int na, ash, na_c, ind, a;
+ int subdiv_z, sub_z, na_z, ash_z;
+ int subdiv_y, sub_y, na_y, ash_y;
+ int subdiv_x, sub_x, na_x, ash_x;
- /* cppcheck-suppress unassignedVariable */
nbnxn_bb_t bb_work_array[2], *bb_work_aligned;
bb_work_aligned = (nbnxn_bb_t *)(((size_t)(bb_work_array+1)) & (~((size_t)15)));
gmx_ns_t *ns;
atom_id **nl_lr_ljc, **nl_lr_one, **nl_sr;
int *nlr_ljc, *nlr_one, *nsr;
- gmx_domdec_t *dd = NULL;
+ gmx_domdec_t *dd;
t_block *cgs = &(top->cgs);
int *cginfo = fr->cginfo;
/* atom_id *i_atoms,*cgsindex=cgs->index; */
ns = &fr->ns;
bDomDec = DOMAINDECOMP(cr);
- if (bDomDec)
- {
- dd = cr->dd;
- }
+ dd = cr->dd;
bTriclinicX = ((YY < grid->npbcdim &&
(!bDomDec || dd->nc[YY] == 1) && box[YY][XX] != 0) ||
*/
/* Determine the shift for the corners of the triclinic box */
add_tric = izones_size[j]*box[j][i]/box[j][j];
- if (dd && dd->ndim == 1 && j == ZZ)
+ if (dd->ndim == 1 && j == ZZ)
{
/* With 1D domain decomposition the cg's are not in
* the triclinic box, but trilinic x-y and rectangular y-z.
static void
init_common(t_topology * /* top */, int /* npar */, gmx_ana_selparam_t *param, void *data)
{
- t_methoddata_distance *d = (t_methoddata_distance *)data;
+ t_methoddata_distance *d = static_cast<t_methoddata_distance *>(data);
if ((param[0].flags & SPAR_SET) && d->cutoff <= 0)
{
static void
init_frame_common(t_topology * /* top */, t_trxframe * /* fr */, t_pbc *pbc, void *data)
{
- t_methoddata_distance *d = (t_methoddata_distance *)data;
+ t_methoddata_distance *d = static_cast<t_methoddata_distance *>(data);
d->nbsearch.reset();
gmx::AnalysisNeighborhoodPositions pos(d->p.x, d->p.count());
evaluate_distance(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
{
- t_methoddata_distance *d = (t_methoddata_distance *)data;
+ t_methoddata_distance *d = static_cast<t_methoddata_distance *>(data);
out->nr = pos->m.mapb.nra;
for (int b = 0; b < pos->count(); ++b)
evaluate_within(t_topology * /* top */, t_trxframe * /* fr */, t_pbc * /* pbc */,
gmx_ana_pos_t *pos, gmx_ana_selvalue_t *out, void *data)
{
- t_methoddata_distance *d = (t_methoddata_distance *)data;
+ t_methoddata_distance *d = static_cast<t_methoddata_distance *>(data);
out->u.g->isize = 0;
for (int b = 0; b < pos->count(); ++b)
* conservative so it works with (inverse) square root, division,
* exponentials, logarithms, and error functions.
*/
- SimdBaseTest()
- {
+ SimdBaseTest() :
#ifdef GMX_DOUBLE
- ulpTol_ = 255LL; // Aim for roughly twice the precision we have in single.
+ ulpTol_(255LL), // Aim for roughly twice the precision we have in single.
#else
- ulpTol_ = 10LL; // Be a bit liberal so compiler optimization doesn't bite us.
+ ulpTol_(10LL), // Be a bit liberal so compiler optimization doesn't bite us.
#endif
- absTol_ = 0;
- range_ = std::pair<real, real>(1, 10);
+ absTol_(0), range_(std::pair<real, real>(1, 10))
+ {
}
/*! \brief Adjust ulp tolerance from the default 10 (float) or 255 (double). */
const char *GromacsException::what() const throw()
{
const ErrorMessage *msg = boost::get_error_info<errinfo_message>(*this);
- while (msg != NULL && msg->isContext())
+ if (msg == NULL)
+ {
+ return "No reason provided";
+ }
+ while (msg->isContext())
{
msg = &msg->child();
}
- return msg != NULL ? msg->text().c_str() : "No reason provided";
+ return msg->text().c_str();
}
void GromacsException::prependContext(const std::string &context)
}
#endif
- allocate_fail = FALSE; /* stop compiler warnings */
#ifdef HAVE_POSIX_MEMALIGN
allocate_fail = (0 != posix_memalign(&malloced, alignment, nelem*elsize));
#elif defined HAVE_MEMALIGN
${CMAKE_SOURCE_DIR}/src/external/*.c
${CMAKE_SOURCE_DIR}/src/external/*.cpp
${CMAKE_SOURCE_DIR}/src/external/*.cu
+ ${CMAKE_SOURCE_DIR}/src/gromacs/selection/scanner.cpp
+ ${CMAKE_SOURCE_DIR}/src/gromacs/selection/parser.cpp
)
list(REMOVE_ITEM _inputfiles ${_files_to_ignore})
set(_outputopt --xml)
endif()
set(_common_flags
- --enable=style -DLINUX
+ --enable=style -DLINUX -DHAVE_UNISTD_H
-I src/gromacs/legacyheaders -I src
-I src/external/thread_mpi/include
-I ${CMAKE_BINARY_DIR}/src -I ${CMAKE_BINARY_DIR}/src/gromacs/utility
--quiet
+ --inline-suppr
${_outputopt})
set(_c_flags
--suppress=variableScope
--suppress=sizeofCalculation
--suppress=missingInclude:src/programs/mdrun/gmx_gpu_utils/gmx_gpu_utils.cu
--suppress=*:src/external/Random123-1.08/include/Random123/features/compilerfeatures.h
- --inline-suppr)
+ --suppress=assignIfError:src/gromacs/mdlib/nbnxn_atomdata.c #Ticket 5695
+ --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
+ )
set(_cxx_flags
-D__cplusplus
--suppress=variableScope
--suppress=unnecessaryForwardDeclaration
--suppress=invalidscanf:src/gromacs/fileio/matio.cpp
--suppress=invalidscanf:src/gromacs/fileio/xvgr.cpp
- --suppress=invalidscanf:src/gromacs/gmxpreprocess/pdb2top.cpp
- --suppress=*:src/gromacs/selection/scanner.cpp)
+ --suppress=invalidscanf:src/gromacs/gmxpreprocess/pdb2top.cpp)
# This list will hold the list of all files with cppcheck errors
# (one per input file)