diff --git a/src/tools/HistogramBead.cpp b/src/tools/HistogramBead.cpp index 3c17ce1442445716ee25296074c80f5c5e3e3d1b..ba54b8951fa2568fe2e4c181b7b9ff6ec7cd9025 100644 --- a/src/tools/HistogramBead.cpp +++ b/src/tools/HistogramBead.cpp @@ -139,7 +139,10 @@ void HistogramBead::generateBins( const std::string& params, std::vector<std::st void HistogramBead::set( const std::string& params, std::string& errormsg ) { std::vector<std::string> data=Tools::getWords(params); - if(data.size()<1) errormsg="No input has been specified"; + if(data.size()<1) { + errormsg="No input has been specified"; + return; + } std::string name=data[0]; const double DP2CUTOFF=6.25; if(name=="GAUSSIAN") { type=gaussian; cutoff=sqrt(2.0*DP2CUTOFF); } diff --git a/src/tools/IFile.cpp b/src/tools/IFile.cpp index 7cb119d2266fa85dba54aa1670bc7b90899cbcc2..1c6c07faa80b2298201e90c15d82a6a3f875e0d3 100644 --- a/src/tools/IFile.cpp +++ b/src/tools/IFile.cpp @@ -64,7 +64,8 @@ IFile& IFile::advanceField() { bool done=false; while(!done) { getline(line); - if(!*this) {return *this;} +// using explicit conversion not to confuse cppcheck 1.86 + if(!bool(*this)) {return *this;} std::vector<std::string> words=Tools::getWords(line); if(words.size()>=2 && words[0]=="#!" && words[1]=="FIELDS") { fields.clear(); @@ -124,7 +125,8 @@ IFile& IFile::open(const std::string&path) { IFile& IFile::scanFieldList(std::vector<std::string>&s) { if(!inMiddleOfField) advanceField(); - if(!*this) return *this; +// using explicit conversion not to confuse cppcheck 1.86 + if(!bool(*this)) return *this; s.clear(); for(unsigned i=0; i<fields.size(); i++) s.push_back(fields[i].name); @@ -141,7 +143,8 @@ bool IFile::FieldExist(const std::string& s) { IFile& IFile::scanField(const std::string&name,std::string&str) { if(!inMiddleOfField) advanceField(); - if(!*this) return *this; +// using explicit conversion not to confuse cppcheck 1.86 + if(!bool(*this)) return *this; unsigned i=findField(name); str=fields[i].value; fields[i].read=true; diff --git a/src/tools/SwitchingFunction.cpp b/src/tools/SwitchingFunction.cpp index 0ede2392482610d9115b76af668b6cf508c47d14..2acf4c7f46d843193c58fca0de6f5de3dc6d3675 100644 --- a/src/tools/SwitchingFunction.cpp +++ b/src/tools/SwitchingFunction.cpp @@ -186,7 +186,10 @@ void SwitchingFunction::registerKeywords( Keywords& keys ) { void SwitchingFunction::set(const std::string & definition,std::string& errormsg) { vector<string> data=Tools::getWords(definition); - if( data.size()<1 ) errormsg="missing all input for switching function"; + if( data.size()<1 ) { + errormsg="missing all input for switching function"; + return; + } string name=data[0]; data.erase(data.begin()); invr0=0.0; diff --git a/src/ves/FermiSwitchingFunction.cpp b/src/ves/FermiSwitchingFunction.cpp index a53ab6f6a3f444ab6a2886dd1a761c00ccab97a0..f0695c4e801f206936cfe3f7a5a4457afc1432d9 100644 --- a/src/ves/FermiSwitchingFunction.cpp +++ b/src/ves/FermiSwitchingFunction.cpp @@ -41,7 +41,10 @@ void FermiSwitchingFunction::registerKeywords( Keywords& keys ) { void FermiSwitchingFunction::set(const std::string& definition,std::string& errormsg) { std::vector<std::string> data=Tools::getWords(definition); - if( data.size()<1 ) errormsg="missing all input for switching function"; + if( data.size()<1 ) { + errormsg="missing all input for switching function"; + return; + } std::string name=data[0]; data.erase(data.begin()); if(name!="FERMI") {errormsg="only FERMI is supported";} diff --git a/src/ves/MD_LinearExpansionPES.cpp b/src/ves/MD_LinearExpansionPES.cpp index d44f0767d63071dfb9efc96e5af5fe19aafdb6cd..f73489b113d241c166171b353b08794677285b4d 100644 --- a/src/ves/MD_LinearExpansionPES.cpp +++ b/src/ves/MD_LinearExpansionPES.cpp @@ -236,8 +236,8 @@ int MD_LinearExpansionPES::main( FILE* in, FILE* out, PLMD::Communicator& pc) { parse("nstep",nsteps); double tstep; parse("tstep",tstep); - // - double temp; + // initialize to solve a cppcheck 1.86 warning + double temp=0.0; std::vector<double> temps_vec(0); parseVector("temperature",temps_vec); if(temps_vec.size()==1) {