From 31005e27814fb8f556f9b8ea8b9b253e21d9b72b Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Mon, 25 May 2015 13:04:53 -0500
Subject: [PATCH] Fixed cppcheck issues and added suppress comments

---
 src/colvar/PCARMSD.cpp | 2 +-
 src/tools/Grid.cpp     | 6 +++---
 src/tools/Tensor.h     | 2 ++
 src/tools/Vector.h     | 4 +++-
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/colvar/PCARMSD.cpp b/src/colvar/PCARMSD.cpp
index 63d4036f8..c5fffc32a 100644
--- a/src/colvar/PCARMSD.cpp
+++ b/src/colvar/PCARMSD.cpp
@@ -152,7 +152,7 @@ PLUMED_COLVAR_INIT(ao),squared(true)
         std::string num; Tools::convert( i, num );
         string name; name=string("eig-")+num;
 	pca_names.push_back(name);
-	addComponentWithDerivatives(name.c_str()); componentIsNotPeriodic(name.c_str());	
+	addComponentWithDerivatives(name); componentIsNotPeriodic(name);
   }  
   turnOnDerivatives();
 
diff --git a/src/tools/Grid.cpp b/src/tools/Grid.cpp
index 8c8378164..3e1fbc6ae 100644
--- a/src/tools/Grid.cpp
+++ b/src/tools/Grid.cpp
@@ -571,9 +571,9 @@ void Grid::writeCubeFile(OFile& ofile){
   ofile.printf("PLUMED CUBE FILE\n");
   ofile.printf("OUTER LOOP: X, MIDDLE LOOP: Y, INNER LOOP: Z\n");
   ofile.printf("%d %f %f %f\n",0,0.0,0.0,0.0); // Number of atoms followed by position of origin
-  ofile.printf("%d %f %f %f\n",nbin_[0],dx_[0],0.0,0.0);  // Number of bins in each direction followed by 
-  ofile.printf("%d %f %f %f\n",nbin_[1],0.0,dx_[1],0.0);  // shape of voxel
-  ofile.printf("%d %f %f %f\n",nbin_[2],0.0,0.0,dx_[2]);
+  ofile.printf("%u %f %f %f\n",nbin_[0],dx_[0],0.0,0.0);  // Number of bins in each direction followed by 
+  ofile.printf("%u %f %f %f\n",nbin_[1],0.0,dx_[1],0.0);  // shape of voxel
+  ofile.printf("%u %f %f %f\n",nbin_[2],0.0,0.0,dx_[2]);
   std::vector<unsigned> pp(3);
   for(pp[0]=0;pp[0]<nbin_[0];++pp[0]){
       for(pp[1]=0;pp[1]<nbin_[1];++pp[1]){
diff --git a/src/tools/Tensor.h b/src/tools/Tensor.h
index 979cf1303..67532c32a 100644
--- a/src/tools/Tensor.h
+++ b/src/tools/Tensor.h
@@ -168,6 +168,8 @@ public:
 };
 
 template<unsigned n,unsigned m>
+// notice that d[] is initialized in LoopUnroller<n*m>::_zero(d);
+// cppcheck-suppress uninitMemberVar
 TensorGeneric<n,m>::TensorGeneric(){
   LoopUnroller<n*m>::_zero(d);
 }
diff --git a/src/tools/Vector.h b/src/tools/Vector.h
index daa1cc563..3b470aa3a 100644
--- a/src/tools/Vector.h
+++ b/src/tools/Vector.h
@@ -178,8 +178,10 @@ void VectorGeneric<n>::zero(){
 }
 
 template <unsigned n>
+// notice that d[] is initialized in LoopUnroller<n>::_zero(d)
+// cppcheck-suppress uninitMemberVar
 VectorGeneric<n>::VectorGeneric(){
-  zero();
+  LoopUnroller<n>::_zero(d);
 }
 
 template <unsigned n>
-- 
GitLab