From ea652f0707a8c1b40f1cd055a701be22c511400b Mon Sep 17 00:00:00 2001 From: Giovanni Bussi <giovanni.bussi@gmail.com> Date: Wed, 12 Dec 2018 07:52:49 +0100 Subject: [PATCH] Fixed some style issues from cppcheck --- src/colvar/ContactMap.cpp | 4 ++-- src/colvar/CoordinationBase.cpp | 4 ++-- src/generic/EffectiveEnergyDrift.cpp | 2 -- src/gridtools/GridToXYZ.cpp | 3 ++- src/tools/Communicator.cpp | 8 -------- src/tools/MolDataClass.cpp | 1 - 6 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/colvar/ContactMap.cpp b/src/colvar/ContactMap.cpp index 07fda44d7..8f81f226f 100644 --- a/src/colvar/ContactMap.cpp +++ b/src/colvar/ContactMap.cpp @@ -271,8 +271,8 @@ void ContactMap::calculate() { Tensor virial; std::vector<Vector> deriv(getNumberOfAtoms()); - unsigned stride=comm.Get_size(); - unsigned rank=comm.Get_rank(); + unsigned stride; + unsigned rank; if(serial) { // when using components the parallelisation do not work stride=1; diff --git a/src/colvar/CoordinationBase.cpp b/src/colvar/CoordinationBase.cpp index 75040505a..2a1d34120 100644 --- a/src/colvar/CoordinationBase.cpp +++ b/src/colvar/CoordinationBase.cpp @@ -140,8 +140,8 @@ void CoordinationBase::calculate() nl->update(getPositions()); } - unsigned stride=comm.Get_size(); - unsigned rank=comm.Get_rank(); + unsigned stride; + unsigned rank; if(serial) { stride=1; rank=0; diff --git a/src/generic/EffectiveEnergyDrift.cpp b/src/generic/EffectiveEnergyDrift.cpp index f4185c0fc..8debb8a80 100644 --- a/src/generic/EffectiveEnergyDrift.cpp +++ b/src/generic/EffectiveEnergyDrift.cpp @@ -222,8 +222,6 @@ void EffectiveEnergyDrift::update() { pNLocalAtoms = pGatindex.size(); pPositions=positions; pForces=forces; - pPositions=positions; - pForces=forces; pbox=box; pfbox=fbox; initialBias=plumed.getBias(); diff --git a/src/gridtools/GridToXYZ.cpp b/src/gridtools/GridToXYZ.cpp index fd22d2a88..d2d8365bd 100644 --- a/src/gridtools/GridToXYZ.cpp +++ b/src/gridtools/GridToXYZ.cpp @@ -97,7 +97,8 @@ void GridToXYZ::printGrid( OFile& ofile ) const { ofile.printf("Grid converted to xyz file \n"); for(unsigned i=0; i<ingrid->getNumberOfPoints(); ++i) { ingrid->getGridPointCoordinates( i, point ); - ofile.printf("X"); double val=ingrid->getGridElement( i, 0 ); + ofile.printf("X"); + double val; if( ingrid->getType()=="flat" ) val=1.0; else val=ingrid->getGridElement( i, 0 ); for(unsigned j=0; j<3; ++j) { ofile.printf( (" " + fmt).c_str(), val*lenunit*point[j] ); } diff --git a/src/tools/Communicator.cpp b/src/tools/Communicator.cpp index 48acdd345..17e836041 100644 --- a/src/tools/Communicator.cpp +++ b/src/tools/Communicator.cpp @@ -34,20 +34,12 @@ Communicator::Communicator() { } -// cppcheck complains about this: -// Member variable 'Communicator::communicator' is not initialized in the constructor -// this is a false positive so I suppress it -// cppcheck-suppress uninitMemberVar Communicator::Communicator(const Communicator&pc) { Set_comm(pc.communicator); } Communicator::Status Communicator::StatusIgnore; -// cppcheck complains about this: -// Member variable 'Communicator::communicator' is not assigned a value in 'Communicator::operator=' -// this is a false positive so I suppress it -// cppcheck-suppress operatorEqVarError Communicator& Communicator::operator=(const Communicator&pc) { if (this != &pc) { Set_comm(pc.communicator); diff --git a/src/tools/MolDataClass.cpp b/src/tools/MolDataClass.cpp index 107ed2ee3..fa7ddd301 100644 --- a/src/tools/MolDataClass.cpp +++ b/src/tools/MolDataClass.cpp @@ -206,7 +206,6 @@ void MolDataClass::specialSymbol( const std::string& type, const std::string& sy std::string chainid; if(firstnum==dash+1) { Tools::convert( symbol.substr(dash+1), resnum ); - resname= mypdb.getResidueName(resnum); chainid="*"; // this is going to match the first chain } else { // if chain id is provided: -- GitLab