From 18b145f8442c921347a07ec6c5bf0f853defcfd5 Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Wed, 9 Jan 2013 16:08:44 +0100
Subject: [PATCH] Fixed most warning from cppcheck

I used cppcheck --enable=all.
---
 src/Makefile                            |  2 +-
 src/analysis/Analysis.cpp               |  6 ++--
 src/analysis/Histogram.cpp              |  1 -
 src/bias/MovingRestraint.cpp            |  2 +-
 src/cltools/Driver.cpp                  | 17 +++++----
 src/cltools/SimpleMD.cpp                |  4 +--
 src/colvar/PathMSDBase.cpp              |  2 +-
 src/colvar/PropertyMap.cpp              |  1 -
 src/core/Action.cpp                     |  1 -
 src/core/Action.h                       |  1 -
 src/core/ActionSet.h                    |  1 -
 src/core/ActionWithArguments.cpp        |  5 ++-
 src/core/Atoms.cpp                      |  2 +-
 src/core/CLTool.cpp                     |  2 +-
 src/core/CubicInterpolation.cpp         |  3 +-
 src/core/ExchangePatterns.cpp           |  2 ++
 src/core/GREX.cpp                       |  2 ++
 src/core/SetupMolInfo.cpp               |  2 +-
 src/core/Value.cpp                      |  4 +++
 src/function/FuncPathMSD.cpp            |  1 -
 src/function/Piecewise.cpp              |  3 +-
 src/generic/Read.cpp                    |  2 +-
 src/main/main.cpp                       |  2 +-
 src/multicolvar/ActionVolume.cpp        |  3 +-
 src/multicolvar/AlphaRMSD.cpp           |  4 +--
 src/multicolvar/CoordinationNumbers.cpp |  4 +--
 src/multicolvar/MultiColvar.cpp         |  3 +-
 src/multicolvar/VolumeSubcell.cpp       |  5 ++-
 src/tools/Communicator.h                |  4 ++-
 src/tools/DLLoader.cpp                  | 11 ------
 src/tools/DRMSD.h                       |  2 ++
 src/tools/DynamicList.h                 |  2 ++
 src/tools/HistogramBead.cpp             | 22 +++++++++---
 src/tools/HistogramBead.h               |  6 ----
 src/tools/Kearsley.cpp                  | 46 ++++++++++++-------------
 src/tools/KernelFunctions.cpp           |  2 +-
 src/tools/KernelFunctions.h             |  2 --
 src/tools/Keywords.cpp                  |  5 ++-
 src/tools/Matrix.h                      | 10 +++---
 src/tools/OptimalAlignment.cpp          | 12 +++----
 src/tools/RMSD.cpp                      |  5 +++
 src/tools/RMSD.h                        |  4 +--
 src/tools/SwitchingFunction.cpp         |  9 ++++-
 src/tools/Tools.cpp                     |  2 +-
 src/tools/Tools.h                       |  1 -
 src/vesselbase/ActionWithVessel.cpp     |  1 -
 src/vesselbase/Vessel.cpp               |  1 -
 src/vesselbase/VesselMoment.cpp         |  1 -
 48 files changed, 124 insertions(+), 111 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 6c66d48dd..05cd82592 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -20,7 +20,7 @@ $(SUBDIRSCLEAN): %.clean:
 
 .PHONY: cppcheck
 cppcheck:
-	cppcheck --std=c++03 --std=posix -j 4 --platform=unix64 -q --enable=portability,performance */*.{h,cpp}
+	cppcheck --std=c++03 --std=posix -j 4 --platform=unix64 -q --enable=all */*.{h,cpp}
 
 .PHONY: help
 help:
diff --git a/src/analysis/Analysis.cpp b/src/analysis/Analysis.cpp
index da39c2d6d..d55a3dcac 100644
--- a/src/analysis/Analysis.cpp
+++ b/src/analysis/Analysis.cpp
@@ -125,8 +125,8 @@ old_norm(0.0)
 
       parseFlag("USE_ALL_DATA",single_run); 
       if( !single_run ){
-          std::string fstr; parse("RUN",freq );
-          log.printf("  running analysis every %d steps\n",freq);
+          parse("RUN",freq );
+          log.printf("  running analysis every %u steps\n",freq);
           if( freq%getStride()!= 0 ) error("Frequncy of running is not a multiple of the stride");
           ndata=std::floor(freq/getStride() );
           data.resize( ndata );
@@ -157,7 +157,7 @@ old_norm(0.0)
           if( write_chq ) rfile.open( filename.c_str(), "aw" );
           // Run the analysis if we stoped in the middle of it last time
           if( idata==ndata ) runAnalysis();
-          log.printf("  restarting analysis with %d points read from restart file\n",idata);
+          log.printf("  restarting analysis with %u points read from restart file\n",idata);
       } else if( write_chq ){
           // Setup the restart file (delete any old one)
           remove( filename.c_str() ); 
diff --git a/src/analysis/Histogram.cpp b/src/analysis/Histogram.cpp
index 1e06b421a..aa734a561 100644
--- a/src/analysis/Histogram.cpp
+++ b/src/analysis/Histogram.cpp
@@ -92,7 +92,6 @@ private:
   std::vector<double> point, bw;
   std::vector<unsigned> gbin;
   unsigned nfiles;
-  bool nomemory;
   std::string gridfname;
   std::string kerneltype; 
 public:
diff --git a/src/bias/MovingRestraint.cpp b/src/bias/MovingRestraint.cpp
index df40eeb57..46267cd7d 100644
--- a/src/bias/MovingRestraint.cpp
+++ b/src/bias/MovingRestraint.cpp
@@ -145,7 +145,7 @@ verse(getNumberOfArguments())
   checkRead();
 
   for(unsigned i=0;i<step.size();i++){
-    log.printf("  step%d %d\n",i,step[i]);
+    log.printf("  step%u %d\n",i,step[i]);
     log.printf("  at");
     for(unsigned j=0;j<at[i].size();j++) log.printf(" %f",at[i][j]);
     log.printf("\n");
diff --git a/src/cltools/Driver.cpp b/src/cltools/Driver.cpp
index ee3dcceef..a9bd0ecbe 100644
--- a/src/cltools/Driver.cpp
+++ b/src/cltools/Driver.cpp
@@ -202,9 +202,9 @@ int Driver<real>::main(FILE* in,FILE*out,Communicator& pc){
        pbc_cli_given=true;
        vector<string> words=Tools::getWords(pbc_cli_list,",");
        if(words.size()==3){
-         for(int i=0;i<3;i++) sscanf(words[i].c_str(),"%lf",&(pbc_cli_box[4*i]));
+         for(int i=0;i<3;i++) sscanf(words[i].c_str(),"%100lf",&(pbc_cli_box[4*i]));
        } else if(words.size()==9) {
-         for(int i=0;i<9;i++) sscanf(words[i].c_str(),"%lf",&(pbc_cli_box[i]));
+         for(int i=0;i<9;i++) sscanf(words[i].c_str(),"%100lf",&(pbc_cli_box[i]));
        } else {
          string msg="ERROR: cannot parse command-line box "+pbc_cli_list;
          fprintf(stderr,"%s\n",msg.c_str());
@@ -295,9 +295,8 @@ int Driver<real>::main(FILE* in,FILE*out,Communicator& pc){
     } else if ( plumedStopCondition ) break;
 
     int natoms;
-    bool ok;
     bool first_step=false;
-    if(!noatoms) sscanf(line.c_str(),"%d",&natoms);
+    if(!noatoms) sscanf(line.c_str(),"%100d",&natoms);
     if(checknatoms<0 && !noatoms){
       pd_nlocal=natoms;
       pd_start=0;
@@ -382,7 +381,7 @@ int Driver<real>::main(FILE* in,FILE*out,Communicator& pc){
     }
 
     if(!noatoms){
-       ok=Tools::getline(fp,line);
+       bool ok=Tools::getline(fp,line);
        plumed_massert(ok,"premature end of file");
 
        std::vector<double> celld(9,0.0);
@@ -390,9 +389,9 @@ int Driver<real>::main(FILE* in,FILE*out,Communicator& pc){
          std::vector<std::string> words;
          words=Tools::getWords(line);
          if(words.size()==3){
-           sscanf(line.c_str(),"%lf %lf %lf",&celld[0],&celld[4],&celld[8]);
+           sscanf(line.c_str(),"%100lf %100lf %100lf",&celld[0],&celld[4],&celld[8]);
          } else if(words.size()==9){
-           sscanf(line.c_str(),"%lf %lf %lf %lf %lf %lf %lf %lf %lf",
+           sscanf(line.c_str(),"%100lf %100lf %100lf %100lf %100lf %100lf %100lf %100lf %100lf",
                   &celld[0], &celld[1], &celld[2],
                   &celld[3], &celld[4], &celld[5],
                   &celld[6], &celld[7], &celld[8]);
@@ -404,11 +403,11 @@ int Driver<real>::main(FILE* in,FILE*out,Communicator& pc){
 
        // Read coordinates
        for(int i=0;i<natoms;i++){
-         ok=Tools::getline(fp,line);
+         bool ok=Tools::getline(fp,line);
          plumed_massert(ok,"premature end of file");
          char dummy[1000];
          double cc[3];
-         std::sscanf(line.c_str(),"%s %lf %lf %lf",dummy,&cc[0],&cc[1],&cc[2]);
+         std::sscanf(line.c_str(),"%999s %100lf %100lf %100lf",dummy,&cc[0],&cc[1],&cc[2]);
          if(!debug_pd || ( i>=pd_start && i<pd_start+pd_nlocal) ){
            coordinates[3*i]=real(cc[0]);
            coordinates[3*i+1]=real(cc[1]);
diff --git a/src/cltools/SimpleMD.cpp b/src/cltools/SimpleMD.cpp
index f4ad6da29..24e0cc9a5 100644
--- a/src/cltools/SimpleMD.cpp
+++ b/src/cltools/SimpleMD.cpp
@@ -170,14 +170,14 @@ read_input(double& temperature,
       exit(1);
   }
   std::string nconfstr; parse("nconfig",nconfstr);
-  sscanf(nconfstr.c_str(),"%d %s",&nconfig,buffer1);
+  sscanf(nconfstr.c_str(),"%100d %255s",&nconfig,buffer1);
   trajfile=buffer1;
   if(trajfile.length()==0){
       fprintf(stderr,"Specify traj file\n");
       exit(1);
   }
   std::string nstatstr; parse("nstat",nstatstr);
-  sscanf(nstatstr.c_str(),"%d %s",&nstat,buffer1);
+  sscanf(nstatstr.c_str(),"%100d %255s",&nstat,buffer1);
   statfile=buffer1;
   if(statfile.length()==0){
       fprintf(stderr,"Specify stat file\n");
diff --git a/src/colvar/PathMSDBase.cpp b/src/colvar/PathMSDBase.cpp
index 574631a94..945f40b11 100644
--- a/src/colvar/PathMSDBase.cpp
+++ b/src/colvar/PathMSDBase.cpp
@@ -81,7 +81,7 @@ nframes(0)
   } 
   if(neigh_stride>0. || neigh_size>0){
            if(neigh_size>nframes){
-           	log.printf(" List size required ( %d ) is too large: resizing to the maximum number of frames required: %d  \n",neigh_size,nframes);
+           	log.printf(" List size required ( %d ) is too large: resizing to the maximum number of frames required: %u  \n",neigh_size,nframes);
  		neigh_size=nframes;
            }
            log.printf("  Neighbor list enabled: \n");
diff --git a/src/colvar/PropertyMap.cpp b/src/colvar/PropertyMap.cpp
index 888900d86..c57d2ff0d 100644
--- a/src/colvar/PropertyMap.cpp
+++ b/src/colvar/PropertyMap.cpp
@@ -97,7 +97,6 @@ PathMSDBase(ao)
 	char buf[500];
         sprintf(buf,"Need to specify PROPERTY with this action\n");
         plumed_merror(buf);
-        exit(0);
   }else{
       for(unsigned i=0;i<labels.size();i++){
 	log<<" found custom propety to be found in the REMARK line: "<<labels[i].c_str()<<"\n";
diff --git a/src/core/Action.cpp b/src/core/Action.cpp
index 6aa4c9239..398f2af39 100644
--- a/src/core/Action.cpp
+++ b/src/core/Action.cpp
@@ -196,7 +196,6 @@ void Action::error( const std::string & msg ){
   log.printf("ERROR in input to action %s with label %s : %s \n \n", name.c_str(), label.c_str(), msg.c_str() );
   if( !line.empty() ) keywords.print( log );
   plumed_merror("ERROR in input to action " + name + " with label " + label + " : " + msg );
-  this->exit(1);
 }
 
 void Action::warning( const std::string & msg ){
diff --git a/src/core/Action.h b/src/core/Action.h
index 5cf1f01b2..88a349b2c 100644
--- a/src/core/Action.h
+++ b/src/core/Action.h
@@ -297,7 +297,6 @@ bool Action::parseNumbered(const std::string&key, const int no, T&t){
   if( !keywords.numbered(key) ) error("numbered keywords are not allowed for " + key );
 
   // Now try to read the keyword
-  std::string def;
   std::string num; Tools::convert(no,num);
   return Tools::parse(line,key+num,t);
 }
diff --git a/src/core/ActionSet.h b/src/core/ActionSet.h
index 0e9aceeae..b5086aee9 100644
--- a/src/core/ActionSet.h
+++ b/src/core/ActionSet.h
@@ -79,7 +79,6 @@ std::vector<T> ActionSet::select()const{
 
 template <class T>
 T ActionSet::selectWithLabel(const std::string&s)const{
-  std::vector<T> ret;
   for(const_iterator p=begin();p!=end();++p){
     T t=dynamic_cast<T>(*p);
     if(t && dynamic_cast<Action*>(t)->getLabel()==s) return t;
diff --git a/src/core/ActionWithArguments.cpp b/src/core/ActionWithArguments.cpp
index 039c37f41..56f0e6424 100644
--- a/src/core/ActionWithArguments.cpp
+++ b/src/core/ActionWithArguments.cpp
@@ -59,7 +59,7 @@ void ActionWithArguments::parseArgumentList(const std::string&key,std::vector<Va
            // Take components from all actions with a specific name
            std::vector<ActionWithValue*> all=plumed.getActionSet().select<ActionWithValue*>();
            if( all.empty() ) error("your input file is not telling plumed to calculate anything");
-           std::string lab; unsigned nval=0;
+           unsigned nval=0;
            for(unsigned j=0;j<all.size();j++){
               std::string flab; flab=all[j]->getLabel() + "." + name;
               if( all[j]->exists(flab) ){ arg.push_back(all[j]->copyOutput(flab)); nval++; }
@@ -76,7 +76,7 @@ void ActionWithArguments::parseArgumentList(const std::string&key,std::vector<Va
            if( !(action->exists(c[i])) ){
                  std::string str=" (hint! the components in this actions are: "; 
                  str+=action->getComponentsList()+")";
-		 error("action " + a + " has no component named " + name );
+		 error("action " + a + " has no component named " + name + str);
 	   } ;
            arg.push_back(action->copyOutput(c[i]));
         }
@@ -162,7 +162,6 @@ void ActionWithArguments::calculateNumericalDerivatives( ActionWithValue* a ){
   }
   a->calculate();
   a->clearDerivatives();
-  std::vector<double> value0(nval);
   for(unsigned j=0;j<nval;j++){
     Value* v=a->copyOutput(j);
     if( v->hasDerivatives() ) for(int i=0;i<npar;i++) v->addDerivative(i,(value[i*nval+j]-a->getOutputQuantity(j))/sqrt(epsilon));
diff --git a/src/core/Atoms.cpp b/src/core/Atoms.cpp
index 3cb8a59ff..5d9a5ff27 100644
--- a/src/core/Atoms.cpp
+++ b/src/core/Atoms.cpp
@@ -175,9 +175,9 @@ void Atoms::wait(){
 
   if(dd && int(gatindex.size())<natoms){
 // receive toBeReceived
-    int count=0;
     Communicator::Status status;
     if(dd.async){
+      int count=0;
       for(int i=0;i<dd.Get_size();i++){
         dd.Recv(&dd.indexToBeReceived[count],dd.indexToBeReceived.size()-count,i,666,status);
         int c=status.Get_count<int>();
diff --git a/src/core/CLTool.cpp b/src/core/CLTool.cpp
index de7536df1..a97dd192f 100644
--- a/src/core/CLTool.cpp
+++ b/src/core/CLTool.cpp
@@ -164,7 +164,7 @@ bool CLTool::readInputFile( int argc, char**argv, FILE* in, FILE*out ){
      for(int i=0;i<line.length();++i) if(line[i]=='#' || line[i]=='\n') line.erase(i);
      Tools::stripLeadingAndTrailingBlanks( line );
      if(line.length()==0) continue;
-     sscanf(line.c_str(),"%s",buffer);
+     sscanf(line.c_str(),"%255s",buffer);
      std::string keyword=buffer; bool found=false;
      for(unsigned i=0;i<keywords.size();++i){
          std::string thiskey=keywords.get(i);
diff --git a/src/core/CubicInterpolation.cpp b/src/core/CubicInterpolation.cpp
index 00f2bbde5..0f0f02655 100644
--- a/src/core/CubicInterpolation.cpp
+++ b/src/core/CubicInterpolation.cpp
@@ -68,13 +68,12 @@ unsigned CInterpolation::findBox( const std::vector<double>& pos ){
      bnew+=ccf_box; 
   }
   plumed_assert( bold==0 ); bold=bnew;
-  unsigned mm=std::floor(double(bnew)/double(stride[0]));
   for(unsigned i=0;i<np.size();++i){ lb[i]=splinepoints(bold,i); ub[i]=splinepoints(bold+stride[i],i); }
   return bold;
 }
 
 unsigned CInterpolation::search1( const unsigned& kk, const double& x, const unsigned& jold ) const {
-    int inc=stride[kk], n=np[kk]*stride[kk], jl=jold*stride[kk], ju=(jold+1)*stride[kk], jm; 
+    int inc=stride[kk], jl=jold*stride[kk], ju=(jold+1)*stride[kk], jm; 
     if ( x>=splinepoints(jl,kk) && x<splinepoints( ju, kk ) ) return jl;
     else {
         if( x>=splinepoints(jl, kk ) ){
diff --git a/src/core/ExchangePatterns.cpp b/src/core/ExchangePatterns.cpp
index c940084c9..707dff971 100644
--- a/src/core/ExchangePatterns.cpp
+++ b/src/core/ExchangePatterns.cpp
@@ -27,6 +27,8 @@ using namespace std;
 namespace PLMD{
 
 ExchangePatterns::ExchangePatterns():
+  PatternFlag(NONE),
+  NumberOfReplicas(1),
   random(*new Random)
 {}
 
diff --git a/src/core/GREX.cpp b/src/core/GREX.cpp
index 737a1aa6b..367273bfc 100644
--- a/src/core/GREX.cpp
+++ b/src/core/GREX.cpp
@@ -36,6 +36,8 @@ GREX::GREX(PlumedMain&p):
   plumedMain(p),
   atoms(p.getAtoms()),
   partner(-1), // = unset
+  localDeltaBias(0),
+  foreignDeltaBias(0),
   myreplica(-1) // = unset
 {
   p.setSuffix(".NA");
diff --git a/src/core/SetupMolInfo.cpp b/src/core/SetupMolInfo.cpp
index d2b7dda65..a00ebb154 100644
--- a/src/core/SetupMolInfo.cpp
+++ b/src/core/SetupMolInfo.cpp
@@ -82,7 +82,7 @@ pdb(*new(PDB))
        AtomNumber astart,aend; 
        pdb.getAtomRange( chains[i], astart, aend, errmsg );
        if( errmsg.length()!=0 ) error( errmsg );
-       log.printf("  chain named %s contains residues %d to %d and atoms %d to %d \n",chains[i].c_str(),start,end,astart.serial(),aend.serial());
+       log.printf("  chain named %s contains residues %u to %u and atoms %d to %d \n",chains[i].c_str(),start,end,astart.serial(),aend.serial());
     }
   }
   pdb.renameAtoms("HA1","CB");  // This is a hack to make this work with GLY residues 
diff --git a/src/core/Value.cpp b/src/core/Value.cpp
index 1b3d82932..d3592bf9e 100644
--- a/src/core/Value.cpp
+++ b/src/core/Value.cpp
@@ -34,6 +34,8 @@ Value::Value():
   action(NULL), 
   value_set(false), 
   value(0.0), 
+  inputForce(0.0),
+  hasForce(false),
   hasDeriv(true), 
   periodicity(unset), 
   min(0.0), 
@@ -47,6 +49,8 @@ Value::Value(ActionWithValue* av, const std::string& name, const bool withderiv)
   action(av),
   value_set(false),
   value(0.0),
+  inputForce(0.0),
+  hasForce(false),
   name(name),
   hasDeriv(withderiv),
   periodicity(unset),
diff --git a/src/function/FuncPathMSD.cpp b/src/function/FuncPathMSD.cpp
index 71209a3b2..40a8b8003 100644
--- a/src/function/FuncPathMSD.cpp
+++ b/src/function/FuncPathMSD.cpp
@@ -140,7 +140,6 @@ neigh_stride(-1.)
   // list the action involved and check the type 
   for(unsigned i=0;i<getNumberOfArguments();i++){
        // for each value get the name and the label of the corresponding action
-       std::string mylabel=getPntrToArgument(i)->getPntrToAction()->getLabel(); 
        std::string myname=getPntrToArgument(i)->getPntrToAction()->getName(); 
        if(myname!="RMSD")plumed_merror("This argument is not of RMSD type!!!");
   }   
diff --git a/src/function/Piecewise.cpp b/src/function/Piecewise.cpp
index 4ff371a87..7f559a78b 100644
--- a/src/function/Piecewise.cpp
+++ b/src/function/Piecewise.cpp
@@ -92,7 +92,8 @@ void Piecewise::registerKeywords(Keywords& keys){
 
 Piecewise::Piecewise(const ActionOptions&ao):
 Action(ao),
-Function(ao)
+Function(ao),
+normalize(false)
 {
   for(int i=0;;i++){
     std::vector<double> pp;
diff --git a/src/generic/Read.cpp b/src/generic/Read.cpp
index e4af6ef94..d2daae687 100644
--- a/src/generic/Read.cpp
+++ b/src/generic/Read.cpp
@@ -99,7 +99,7 @@ nlinesPerStep(1)
       ifile->allowIgnoredFields();
   }
   parse("EVERY",nlinesPerStep);
-  if(nlinesPerStep>1) log.printf("  only reading every %dth line of file %s\n",nlinesPerStep,filename.c_str() );
+  if(nlinesPerStep>1) log.printf("  only reading every %uth line of file %s\n",nlinesPerStep,filename.c_str() );
   else log.printf("  reading data from file %s\n",filename.c_str() );
   // Find out what we are reading
   std::vector<std::string> valread; parseVector("VALUES",valread);
diff --git a/src/main/main.cpp b/src/main/main.cpp
index bec8db5cf..d98450c08 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -36,9 +36,9 @@ using namespace std;
   to avoid linker error.
 */
 int main(int argc,char**argv){
+#ifdef __PLUMED_MPI
   bool nompi=false;
   if(argc>1 && !strcmp(argv[1],"--no-mpi")) nompi=true;
-#ifdef __PLUMED_MPI
   if(!nompi) MPI_Init(&argc,&argv);
 #endif
   int ret;
diff --git a/src/multicolvar/ActionVolume.cpp b/src/multicolvar/ActionVolume.cpp
index 1869262e5..a618cf053 100644
--- a/src/multicolvar/ActionVolume.cpp
+++ b/src/multicolvar/ActionVolume.cpp
@@ -31,7 +31,8 @@ void ActionVolume::registerKeywords( Keywords& keys ){
 
 ActionVolume::ActionVolume(const ActionOptions&ao):
 Action(ao),
-ActionAtomistic(ao)
+ActionAtomistic(ao),
+sigma(0.0)
 {
 }
 
diff --git a/src/multicolvar/AlphaRMSD.cpp b/src/multicolvar/AlphaRMSD.cpp
index e130f7da3..49d453b5f 100644
--- a/src/multicolvar/AlphaRMSD.cpp
+++ b/src/multicolvar/AlphaRMSD.cpp
@@ -99,10 +99,10 @@ SecondaryStructureRMSD(ao)
   readBackboneAtoms( backnames, chains);
 
   // This constructs all conceivable sections of alpha helix in the backbone of the chains
-  unsigned nres, n, nprevious=0; std::vector<unsigned> nlist(30);
+  unsigned nres, nprevious=0; std::vector<unsigned> nlist(30);
   for(unsigned i=0;i<chains.size();++i){
      if( chains[i]<30 ) error("segment of backbone defined is not long enough to form an alpha helix. Each backbone fragment must contain a minimum of 6 residues");
-     nres=chains[i]/5; plumed_assert( chains[i]%5==0 ); n=0;
+     nres=chains[i]/5; plumed_assert( chains[i]%5==0 );
      for(unsigned ires=0;ires<nres-5;ires++){
        unsigned accum=nprevious + 5*ires; 
        for(unsigned k=0;k<30;++k) nlist[k] = accum+k;
diff --git a/src/multicolvar/CoordinationNumbers.cpp b/src/multicolvar/CoordinationNumbers.cpp
index f36582647..4ea8345ff 100644
--- a/src/multicolvar/CoordinationNumbers.cpp
+++ b/src/multicolvar/CoordinationNumbers.cpp
@@ -133,9 +133,9 @@ double CoordinationNumbers::compute( const unsigned& j, const std::vector<Vector
    double value=0, dfunc; Vector distance;
 
    // Calculate the coordination number
-   double dd, sw;
+   double sw;
    for(unsigned i=1;i<pos.size();++i){
-      distance=getSeparation( pos[0], pos[i] ); dd=distance.modulo();
+      distance=getSeparation( pos[0], pos[i] );
       sw = switchingFunction.calculate( distance.modulo(), dfunc );
       if( sw>=getTolerance() ){    //  nl_cut<0 ){
          value += sw;             // switchingFunction.calculate( distance.modulo(), dfunc );
diff --git a/src/multicolvar/MultiColvar.cpp b/src/multicolvar/MultiColvar.cpp
index 6b7c3c129..48f98e83c 100644
--- a/src/multicolvar/MultiColvar.cpp
+++ b/src/multicolvar/MultiColvar.cpp
@@ -70,7 +70,8 @@ usepbc(true),
 readatoms(false),
 verbose_output(false),
 needsCentralAtomPosition(false),
-catom_pos(3)
+catom_pos(3),
+current(0)
 {
   if( keywords.exists("NOPBC") ){ 
     bool nopbc=!usepbc; parseFlag("NOPBC",nopbc);
diff --git a/src/multicolvar/VolumeSubcell.cpp b/src/multicolvar/VolumeSubcell.cpp
index 5467b7f4e..124300fef 100644
--- a/src/multicolvar/VolumeSubcell.cpp
+++ b/src/multicolvar/VolumeSubcell.cpp
@@ -70,7 +70,10 @@ void VolumeSubcell::registerKeywords( Keywords& keys ){
 
 VolumeSubcell::VolumeSubcell(const ActionOptions& ao):
 Action(ao),
-ActionVolume(ao)
+ActionVolume(ao),
+xsmearp(0.0),
+ysmearp(0.0),
+zsmearp(0.0)
 {
 
   dox=true; parse("XLOWER",xlow); parse("XUPPER",xhigh);
diff --git a/src/tools/Communicator.h b/src/tools/Communicator.h
index 3caf3aade..d81f7035c 100644
--- a/src/tools/Communicator.h
+++ b/src/tools/Communicator.h
@@ -33,6 +33,8 @@ namespace PLMD{
 /// Surrogate of MPI types when MPI library is not available
   class MPI_Comm {
     int dummy;
+  public:
+    MPI_Comm():dummy(0){};
   };
 #endif
 
@@ -230,8 +232,8 @@ int Communicator::Status::Get_count()const{
   plumed_massert(initialized(),"you are trying to use an MPI function, but MPI is not initialized");
   MPI_Get_count(const_cast<MPI_Status*>(&s),getMPIType<T>(),&i);
 #else
-  plumed_merror("you are trying to use an MPI function, but PLUMED has been compiled without MPI support");
   i=0;
+  plumed_merror("you are trying to use an MPI function, but PLUMED has been compiled without MPI support");
 #endif
   return i;
 }
diff --git a/src/tools/DLLoader.cpp b/src/tools/DLLoader.cpp
index d26c77ed1..88230758a 100644
--- a/src/tools/DLLoader.cpp
+++ b/src/tools/DLLoader.cpp
@@ -65,20 +65,9 @@ DLLoader::~DLLoader(){
 #endif
 }
 
-DLLoader::DLLoader(const DLLoader&dl){
-  plumed_merror("this should never be called");
-}
-
 DLLoader::DLLoader(){
   // do nothing
 }
 
-DLLoader&DLLoader::operator=(const DLLoader&dl){
-  plumed_merror("this should never be called");
-  return *this;
-}
-
-
-
 
 }
diff --git a/src/tools/DRMSD.h b/src/tools/DRMSD.h
index e0dfbabbe..facc4e541 100644
--- a/src/tools/DRMSD.h
+++ b/src/tools/DRMSD.h
@@ -38,6 +38,8 @@ class DRMSD {
   std::map< std::pair <unsigned,unsigned> , double> targets;
   unsigned natoms;
   public:
+/// Constructor
+  DRMSD(): natoms(0) {};
 /// clear the structure
   void clear();
 /// set reference, align and displace from input pdb structure
diff --git a/src/tools/DynamicList.h b/src/tools/DynamicList.h
index 269fffabb..f61eb5577 100644
--- a/src/tools/DynamicList.h
+++ b/src/tools/DynamicList.h
@@ -141,6 +141,8 @@ private:
 /// This is the list of active members
   std::vector<T> active;
 public:
+/// Constructor
+  DynamicList():inactive(true){}
 /// An operator that returns the element from the current active list
   inline T operator [] (const unsigned& i) const { 
      plumed_assert(!inactive); plumed_assert( i<active.size() );
diff --git a/src/tools/HistogramBead.cpp b/src/tools/HistogramBead.cpp
index 267a8abe3..c8987c8b0 100644
--- a/src/tools/HistogramBead.cpp
+++ b/src/tools/HistogramBead.cpp
@@ -82,6 +82,20 @@ w_j(s) = \int_{a + \frac{j-1}{n}(b-a)}^{a + \frac{j}{n}(b-a)} \sum_i K\left( \fr
 */
 //+ENDPLUMEDOC
 
+HistogramBead::HistogramBead():
+init(false),
+lowb(0.0),
+highb(0.0),
+width(0.0),
+type(gaussian),
+periodicity(unset),
+min(0.0),
+max(0.0),
+max_minus_min(0.0),
+inv_max_minus_min(0.0)
+{
+}
+
 std::string HistogramBead::description() const {
   std::ostringstream ostr;
   ostr<<"betweeen "<<lowb<<" and "<<highb<<" width of gaussian window equals "<<width;
@@ -106,7 +120,7 @@ void HistogramBead::generateBins( const std::string& params, const std::string&
   bool found_b=Tools::parse(data,dd+"SMEAR",smear);
   if(!found_b){ Tools::convert(0.5,smear); }  
   bool usenorm=false; std::string normstr;
-  if(dd=="") bool found_n=Tools::parseFlag(data,dd+"NORM",usenorm);
+  if(dd=="") Tools::parseFlag(data,dd+"NORM",usenorm);
   if(usenorm && dd==""){ normstr="NORM"; } else { normstr=""; } 
 
   std::string lb,ub; double delr = ( range[1]-range[0] ) / static_cast<double>( nbins );
@@ -135,9 +149,9 @@ void HistogramBead::set( const std::string& params, const std::string& dd, std::
   if( !found_r ) errormsg="Upper bound has not been specified use UPPER"; 
   if( lowb>=highb ) errormsg="Lower bound is higher than upper bound"; 
   
-  smear=0.5; bool found_b=Tools::parse(data,dd+"SMEAR",smear);
+  smear=0.5; Tools::parse(data,dd+"SMEAR",smear);
   width=smear*(highb-lowb); init=true;
-  bool usenorm; bool found_n=Tools::parseFlag(data,dd+"NORM",usenorm);
+  bool usenorm; Tools::parseFlag(data,dd+"NORM",usenorm);
 }
 
 void HistogramBead::set( double l, double h, double w){
@@ -174,10 +188,10 @@ double HistogramBead::calculate( double x, double& df ) const {
      df=0;
      if( fabs(lowB)<1. ) df = 1 - fabs(lowB) / width;
      if( fabs(upperB)<1. ) df -= fabs(upperB) / width;
-     double ia, ib;
      if (upperB<=-1. || lowB >=1.){
         f=0.;
      } else { 
+       double ia, ib;
        if( lowB>-1.0 ){ ia=lowB; }else{ ia=-1.0; } 
        if( upperB<1.0 ){ ib=upperB; } else{ ib=1.0; }
        f = (ib*(2.-fabs(ib))-ia*(2.-fabs(ia)))*0.5;
diff --git a/src/tools/HistogramBead.h b/src/tools/HistogramBead.h
index db95661f2..74759a8aa 100644
--- a/src/tools/HistogramBead.h
+++ b/src/tools/HistogramBead.h
@@ -63,12 +63,6 @@ public:
 	void printKeywords(Log& log) const;
 };	
 
-inline
-HistogramBead::HistogramBead():
-init(false)
-{		
-}
-
 inline
 bool HistogramBead::hasBeenSet() const {
   return init;
diff --git a/src/tools/Kearsley.cpp b/src/tools/Kearsley.cpp
index 5e2004fa7..3dcfdc1a9 100644
--- a/src/tools/Kearsley.cpp
+++ b/src/tools/Kearsley.cpp
@@ -34,13 +34,15 @@ namespace PLMD{
 
 // put some notes
 
-Kearsley::Kearsley(const vector<Vector> &p0, const vector<Vector> &p1, const vector<double> &align, Log* &log):log(log){
-	// copy the structure
-	this->p0=p0;
-	this->p1=p1;
-	com0_is_removed=false;
-	com1_is_removed=false;
-	this->align=align;
+Kearsley::Kearsley(const vector<Vector> &p0, const vector<Vector> &p1, const vector<double> &align, Log* &log):
+	log(log),
+	p0(p0),
+	p1(p1),
+	align(align),
+	com0_is_removed(false),
+	com1_is_removed(false),
+	err(0.0)
+{
 	// now make an initial allocation
 //	int n=p0.size();
 	// eventually here one should make a "hard" resize of all the structures
@@ -760,11 +762,8 @@ assignAlign(align1);
 //// get initial value of the error and derivative of it
 olderr=calculate(rmsd);
 log->printf("INITIAL ERROR VALUE: %e\n",olderr);
-//// store the derivative
-vector<Vector> old_derrdp0=derrdp0 ;
-vector<Vector> old_derrdp1=derrdp1 ;
 // store the matrix
-Tensor old_rotmat0on1=rotmat0on1,old_rotmat1on0=rotmat1on0;
+Tensor old_rotmat0on1=rotmat0on1;
 
 //// get initial value of the error and derivative of it
 
@@ -781,11 +780,11 @@ for(unsigned j=0;j<3;j++){
        p1[i][j]-=delta;
        switch(j){
          case 0:
-             log->printf("TESTING: X  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
+             log->printf("TESTING: X  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
          case 1:
-             log->printf("TESTING: Y  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
+             log->printf("TESTING: Y  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
          case 2:
-             log->printf("TESTING: Z  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
+             log->printf("TESTING: Z  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,align[i]);break;
 
        }
    }
@@ -804,12 +803,11 @@ for(unsigned j=0;j<3;j++){
        p0[i][j]-=delta;
        switch(j){
          case 0:
-             log->printf("TESTING: X  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
+             log->printf("TESTING: X  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
          case 1:
-             log->printf("TESTING: Y  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
+             log->printf("TESTING: Y  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
          case 2:
-             log->printf("TESTING: Z  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
-
+             log->printf("TESTING: Z  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,align[i]);break;
        }
    }
 }
@@ -829,13 +827,13 @@ for(l=0;l<3;l++){
        	   int ind=l*3*3*p0.size()+m*3*p0.size()+j*p0.size()+i;
            switch(j){
            	 case 0:
-                log->printf("TESTING: DMATDP0 [ %d ][ %d ]:  X %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP0 [ %u ][ %u ]:  X %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
            	 case 1:
-                log->printf("TESTING: DMATDP0 [ %d ][ %d ]:  Y %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP0 [ %u ][ %u ]:  Y %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
            	 case 2:
-                log->printf("TESTING: DMATDP0 [ %d ][ %d ]:  Z %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP0 [ %u ][ %u ]:  Z %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp0[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp0[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
            }
        }
@@ -858,13 +856,13 @@ for(l=0;l<3;l++){
            switch(j){
 
              case 0:
-                log->printf("TESTING: DMATDP1 [ %d ][ %d ]:  X %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP1 [ %u ][ %u ]:  X %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
              case 1:
-                log->printf("TESTING: DMATDP1 [ %d ][ %d ]:  Y %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP1 [ %u ][ %u ]:  Y %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
              case 2:
-                log->printf("TESTING: DMATDP1 [ %d ][ %d ]:  Z %d ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
+                log->printf("TESTING: DMATDP1 [ %u ][ %u ]:  Z %u ANAL %18.9f NUMER %18.9f DELTA %18.9f ALIGN %6.2f\n",l,m,i,dmatdp1[ind],(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,dmatdp1[ind]-(rotmat0on1[l][m]- old_rotmat0on1[l][m])/delta,align[i]);break;
 
            }
        }
diff --git a/src/tools/KernelFunctions.cpp b/src/tools/KernelFunctions.cpp
index 940f9eff3..4061b0157 100644
--- a/src/tools/KernelFunctions.cpp
+++ b/src/tools/KernelFunctions.cpp
@@ -137,7 +137,7 @@ width(sig)
 }
 
 double KernelFunctions::getCutoff( const double& width ) const {
-  double DP2CUTOFF=6.25;
+  const double DP2CUTOFF=6.25;
   if( ktype==gaussian ) return sqrt(2.0*DP2CUTOFF)*width;
   else if(ktype==triangular ) return width;
   else if(ktype==uniform) return width;
diff --git a/src/tools/KernelFunctions.h b/src/tools/KernelFunctions.h
index 36e508043..64e812047 100644
--- a/src/tools/KernelFunctions.h
+++ b/src/tools/KernelFunctions.h
@@ -47,8 +47,6 @@ private:
 /// Get the cutoff for a kernel
   double getCutoff( const double& width ) const ;
 public:
-/// Does the kernel have derivatives
-  bool hasderivatives;
   KernelFunctions( const std::vector<double>& at, const std::vector<double>& sig, const std::string& type, const double& w, const bool& norm );
 /// Get the dimensionality of the kernel
   unsigned ndim() const;
diff --git a/src/tools/Keywords.cpp b/src/tools/Keywords.cpp
index eb7373948..f6ead3682 100644
--- a/src/tools/Keywords.cpp
+++ b/src/tools/Keywords.cpp
@@ -116,7 +116,7 @@ void Keywords::reserve( const std::string & t, const std::string & k, const std:
 
 void Keywords::reserveFlag( const std::string & k, const bool def, const std::string & d ){
   plumed_assert( !exists(k) && !reserved(k) ); 
-  std::string defstr, flag="flag";
+  std::string defstr;
   if( def ) { defstr="( default=on ) "; } else { defstr="( default=off ) "; }
   types.insert( std::pair<std::string,KeyType>(k,KeyType("flag")) );
   documentation.insert( std::pair<std::string,std::string>(k,defstr + d) ); 
@@ -165,7 +165,7 @@ void Keywords::add( const std::string & t, const std::string & k, const std::str
 } 
 
 void Keywords::addFlag( const std::string & k, const bool def, const std::string & d ){
-  plumed_assert( !exists(k) && !reserved(k) ); std::string defstr, flag="flag";
+  plumed_assert( !exists(k) && !reserved(k) ); std::string defstr;
   if( def ) { defstr="( default=on ) "; } else { defstr="( default=off ) "; }
   types.insert( std::pair<std::string,KeyType>(k,KeyType("flag")) );
   documentation.insert( std::pair<std::string,std::string>(k,defstr + d) );
@@ -188,7 +188,6 @@ void Keywords::remove( const std::string & k ){
 }
 
 bool Keywords::numbered( const std::string & k ) const {
-  unsigned j=0; 
   if( style( k,"atoms") ) return true;
   plumed_massert( allowmultiple.count(k), "Did not find keyword " + k );
   return allowmultiple.find(k)->second;
diff --git a/src/tools/Matrix.h b/src/tools/Matrix.h
index 2e77465a7..2b7251e06 100644
--- a/src/tools/Matrix.h
+++ b/src/tools/Matrix.h
@@ -100,8 +100,8 @@ private:
    /// The data in the matrix
    std::vector<T> data;
 public:
-   Matrix<T>(const unsigned nr=0, const unsigned nc=0 )  : sz(nr*nc), rw(nr), cl(nc), data(nr*nc) {} 
-   Matrix<T>(const Matrix<T>& t) : sz(t.sz), rw(t.rw), cl(t.cl), data(t.data) {} 
+   Matrix(const unsigned nr=0, const unsigned nc=0 )  : sz(nr*nc), rw(nr), cl(nc), data(nr*nc) {} 
+   Matrix(const Matrix<T>& t) : sz(t.sz), rw(t.rw), cl(t.cl), data(t.data) {} 
    /// Resize the matrix 
    void resize( const unsigned nr, const unsigned nc ){ rw=nr; cl=nc; sz=nr*nc; data.resize(sz); }
    /// Return the number of rows
@@ -119,8 +119,10 @@ public:
    }
    /// Set the Matrix equal to another Matrix
    Matrix<T>& operator=(const Matrix<T>& m){
-     plumed_assert( m.rw==rw && m.cl==cl );
-     data=m.data; 
+     sz=m.sz;
+     rw=m.rw;
+     cl=m.cl;
+     data=m.data;
      return *this;
    }
    /// Set the Matrix equal to the value of a standard vector - used for readin
diff --git a/src/tools/OptimalAlignment.cpp b/src/tools/OptimalAlignment.cpp
index 7cdc2ba92..06bcca28e 100644
--- a/src/tools/OptimalAlignment.cpp
+++ b/src/tools/OptimalAlignment.cpp
@@ -352,11 +352,11 @@ double OptimalAlignment::weightedFindiffTest( bool rmsd){
 	       assignP0( p0 );
 	       switch(j){
 	         case 0:
-	             log->printf("TESTING: X  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: X  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 	         case 1:
-	             log->printf("TESTING: Y  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: Y  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 	         case 2:
-	             log->printf("TESTING: Z  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: Z  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp0[i][j],(err-olderr)/delta,derrdp0[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 
 	       }
 	   }
@@ -374,11 +374,11 @@ double OptimalAlignment::weightedFindiffTest( bool rmsd){
 	       assignP1( p1 );
 	       switch(j){
 	         case 0:
-	             log->printf("TESTING: X  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: X  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 	         case 1:
-	             log->printf("TESTING: Y  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: Y  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 	         case 2:
-	             log->printf("TESTING: Z  %4d ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
+	             log->printf("TESTING: Z  %4u ANAL %18.9f NUMER %18.9f DELTA %18.9f DISP %6.2f ALIGN %6.2f \n",i,derrdp1[i][j],(err-olderr)/delta,derrdp1[i][j]-(err-olderr)/delta,displace[i],align[i]);break;
 
 	       }
 	   }
diff --git a/src/tools/RMSD.cpp b/src/tools/RMSD.cpp
index 56843831f..24bfd14df 100644
--- a/src/tools/RMSD.cpp
+++ b/src/tools/RMSD.cpp
@@ -30,6 +30,11 @@
 using namespace std;
 namespace PLMD{
 
+RMSD::RMSD(Log & log ):
+  alignmentMethod(SIMPLE),
+  myoptimalalignment(NULL),
+  log(&log){};
+
 RMSD& RMSD::operator=(const RMSD& v){
   alignmentMethod=v.alignmentMethod;
   reference=v.reference;
diff --git a/src/tools/RMSD.h b/src/tools/RMSD.h
index 19119b04d..24e21712f 100644
--- a/src/tools/RMSD.h
+++ b/src/tools/RMSD.h
@@ -44,8 +44,8 @@ class RMSD
   OptimalAlignment *myoptimalalignment;
   Log *log;
 public:
-/// initialize the log in the constructor
-  RMSD(Log & log ): myoptimalalignment(NULL),log(&log){};
+/// Constructor
+  RMSD(Log & log );
 /// a copy constructor
   RMSD(const RMSD &);
 /// assignment
diff --git a/src/tools/SwitchingFunction.cpp b/src/tools/SwitchingFunction.cpp
index 68cc1dc91..61d35cefa 100644
--- a/src/tools/SwitchingFunction.cpp
+++ b/src/tools/SwitchingFunction.cpp
@@ -180,7 +180,14 @@ double SwitchingFunction::calculate(double distance,double&dfunc)const{
 }
 
 SwitchingFunction::SwitchingFunction():
-  init(false){
+  init(false),
+  type(spline),
+  nn(6),
+  mm(12),
+  invr0(0.0),
+  d0(0.0),
+  dmax(0.0)
+{
 }
 
 void SwitchingFunction::set(int nn,int mm,double r0,double d0){
diff --git a/src/tools/Tools.cpp b/src/tools/Tools.cpp
index f7a12edb9..707a137db 100644
--- a/src/tools/Tools.cpp
+++ b/src/tools/Tools.cpp
@@ -243,9 +243,9 @@ void Tools::interpretLabel(vector<string>&s){
 
 vector<string> Tools::ls(const string&d){
   DIR*dir;
-  struct dirent *ent;
   vector<string> result;
   if ((dir=opendir(d.c_str()))){
+    struct dirent *ent;
     while ((ent = readdir (dir))) if(string(ent->d_name)!="." && string(ent->d_name)!="..") result.push_back(ent->d_name);
     closedir (dir);
   }
diff --git a/src/tools/Tools.h b/src/tools/Tools.h
index 9db36d013..1f0d4bf08 100644
--- a/src/tools/Tools.h
+++ b/src/tools/Tools.h
@@ -142,7 +142,6 @@ void Tools::removeDuplicates(std::vector<T>& vec)
 
 inline
 bool Tools::parseFlag(std::vector<std::string>&line,const std::string&key,bool&val){
-  std::string s;
   for(std::vector<std::string>::iterator p=line.begin();p!=line.end();++p){
     if(key==*p){
       val=true;
diff --git a/src/vesselbase/ActionWithVessel.cpp b/src/vesselbase/ActionWithVessel.cpp
index 48a3902d2..b03ef452a 100644
--- a/src/vesselbase/ActionWithVessel.cpp
+++ b/src/vesselbase/ActionWithVessel.cpp
@@ -140,7 +140,6 @@ void ActionWithVessel::calculateAllVessels( const int& stepn ){
   unsigned rank=comm.Get_rank();
   if(serial){ stride=1; rank=0; }
 
-  std::vector<Value> aux;
   // Reset everything
   for(unsigned j=0;j<functions.size();++j) functions[j]->zero();
 
diff --git a/src/vesselbase/Vessel.cpp b/src/vesselbase/Vessel.cpp
index a2fc3856a..f633d5f02 100644
--- a/src/vesselbase/Vessel.cpp
+++ b/src/vesselbase/Vessel.cpp
@@ -60,7 +60,6 @@ void Vessel::error( const std::string& msg ){
   action->log.printf("ERROR for keyword %s in action %s with label %s : %s \n \n",myname.c_str(), (action->getName()).c_str(), (action->getLabel()).c_str(), msg.c_str() );
   printKeywords();
   plumed_merror("ERROR for keyword " + myname + " in action "  + action->getName() + " with label " + action->getLabel() + " : " + msg );
-  action->exit(1);
 }
 
 }
diff --git a/src/vesselbase/VesselMoment.cpp b/src/vesselbase/VesselMoment.cpp
index d7c846569..737d51412 100644
--- a/src/vesselbase/VesselMoment.cpp
+++ b/src/vesselbase/VesselMoment.cpp
@@ -43,7 +43,6 @@ public:
 PLUMED_REGISTER_VESSEL(VesselMoment,"MOMENTS")
 
 void VesselMoment::reserveKeyword( Keywords& keys ){
-  std::ostringstream ostr;
   keys.reserve("optional","MOMENTS","calculate the moments of the distribution of collective variables. " 
   "The \\f$m\\f$th moment of a distribution is calculated using \\f$\\frac{1}{N} \\sum_{i=1}^N ( s_i - \\overline{s} )^m \\f$, where \\f$\\overline{s}\\f$ is "
   "the average for the distribution.  The moments keyword takes a lists of integers as input or a range.  Each integer is a value of \\f$m\\f$.");  
-- 
GitLab