From: Erik Lindahl Date: Sat, 11 Jul 2015 18:54:44 +0000 (+0200) Subject: Fixed static analyzer warnings X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?p=alexxy%2Fgromacs.git;a=commitdiff_plain;h=6deccc32ac06eb330845870f580d78ef07f1d1c0 Fixed static analyzer warnings Removed code that had no effect since ct_estimate was reassigned in expfit.cpp. Initialize variables that are set/used in different semi-complex switch statements in angle.cpp, and clarify a switch statement. Change-Id: I15bb2942e268eb053644d1f457f136d60bc63cfb --- diff --git a/src/gromacs/correlationfunctions/expfit.cpp b/src/gromacs/correlationfunctions/expfit.cpp index 3b201bf2c9..0cc2c148ca 100644 --- a/src/gromacs/correlationfunctions/expfit.cpp +++ b/src/gromacs/correlationfunctions/expfit.cpp @@ -862,14 +862,6 @@ real fit_acf(int ncorr, int fitfn, const output_env_t oenv, gmx_bool bVerbose, nf_int = std::min(ncorr, (int)(tendfit/dt)); sum = print_and_integrate(debug, nf_int, dt, c1, NULL, 1); - /* Estimate the correlation time for better fitting */ - ct_estimate = 0.5*c1[0]; - for (i = 1; (i < ncorr) && (c1[i] > 0); i++) - { - ct_estimate += c1[i]; - } - ct_estimate *= dt/c1[0]; - if (bPrint) { printf("COR: Correlation time (plain integral from %6.3f to %6.3f ps) = %8.5f ps\n", diff --git a/src/gromacs/trajectoryanalysis/modules/angle.cpp b/src/gromacs/trajectoryanalysis/modules/angle.cpp index 200aed1924..a8a4e0a358 100644 --- a/src/gromacs/trajectoryanalysis/modules/angle.cpp +++ b/src/gromacs/trajectoryanalysis/modules/angle.cpp @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2011,2012,2013,2014, by the GROMACS development team, led by + * Copyright (c) 2011,2012,2013,2014,2015, 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. @@ -686,21 +686,38 @@ Angle::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, { rvec v1, v2; rvec c1, c2; + + // v2 & c2 are conditionally set in the switch statement below, and conditionally + // used in a different switch statement later. Apparently the clang static analyzer + // thinks there are cases where they can be used uninitialzed (which I cannot find), + // but to avoid trouble if we ever change just one of the switch statements it + // makes sense to clear them outside the first switch. + + clear_rvec(v2); + clear_rvec(c2); + switch (g2type_[0]) { case 'z': - clear_rvec(v2); v2[ZZ] = 1.0; - clear_rvec(c2); break; case 's': copy_rvec(sel2_[g].position(0).x(), c2); break; + default: + // do nothing + break; } + dh.selectDataSet(g); for (int n = 0; n < angleCount_[g]; ++n, iter1.nextValue(), iter2.nextValue()) { rvec x[4]; + // x[] will be assigned below based on the number of atoms used to initialize iter1, + // which in turn should correspond perfectly to g1type_[0] (which determines how many we read), + // but unsurprisingly the static analyzer chokes a bit on that. + clear_rvecs(4, x); + real angle; // checkSelections() ensures that this reflects all the involved // positions.