Fix for coverity : 18344, 18422
authorjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Dec 2011 09:53:52 +0000 (09:53 +0000)
committerjthaeder <jthaeder@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 16 Dec 2011 09:53:52 +0000 (09:53 +0000)
TPC/AliTPCMonitorConfig.cxx
TPC/AliTPCMonitorMappingHandler.cxx

index 1d778b8..ea1cca9 100755 (executable)
@@ -129,7 +129,7 @@ AliTPCMonitorConfig::AliTPCMonitorConfig(const AliTPCMonitorConfig &config) :
   fMainYSize(config.fMainYSize),
   fBorderXSize(config.fBorderXSize),
   fBorderYSize(config.fBorderYSize),
-  fButtonXSize(config.fBorderXSize),
+  fButtonXSize(config.fButtonXSize),
   fButtonYSize(config.fButtonYSize),
   fButtonFirstX1(config.fButtonFirstX1),
   fButtonFirstX2(config.fButtonFirstX2),
@@ -161,7 +161,10 @@ AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig&
     fSector=config.fSector;
     fSectorLast=config.fSectorLast;
     fSectorLastDisplayed=config.fSectorLastDisplayed;
+    fSectorArr= new Int_t[36];
+    fFileLast= config.fFileLast;
     fFileLastSet=config.fFileLastSet;
+    fFileCurrent=config.fFileCurrent;
     fEventNext=config.fEventNext;
     fEventNextID=config.fEventNextID;
     fEventProcessed=config.fEventProcessed;
@@ -180,11 +183,15 @@ AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig&
     fMainXSize=config.fMainXSize;
     fMainYSize=config.fMainYSize;
     fBorderXSize=config.fBorderXSize;
+    fBorderYSize=config.fBorderYSize;
+    fButtonXSize=config.fButtonXSize;
     fButtonYSize=config.fButtonYSize;
     fButtonFirstX1=config.fButtonFirstX1;
     fButtonFirstX2=config.fButtonFirstX2;
     fButtonFirstY=config.fButtonFirstY;
     fWrite10Bit=config.fWrite10Bit;
+    fComponents= new Float_t[10];
+    fSamplingFreq=config.fSamplingFreq;
     fPedestals=config.fPedestals;
     fNumOfChannels=config.fNumOfChannels;
     fTimeBins=config.fTimeBins;
@@ -192,11 +199,9 @@ AliTPCMonitorConfig &AliTPCMonitorConfig::operator =(const AliTPCMonitorConfig&
     fFitPulse=config.fFitPulse; 
     fProcOneSector=config.fProcOneSector;
 
-    fFileLast             = config.fFileLast;
-    fFileCurrent          = config.fFileCurrent;
     
-    fSectorArr            = new Int_t[36];    for(Int_t i =0; i<36; i++) { fSectorArr[i]  =  0;}
-    fComponents           = new Float_t[10];  for(Int_t i =0; i<10;i++)  { fComponents[i] =0.0;}
+    for(Int_t i =0; i<36; i++) { fSectorArr[i]  =  0;}
+    for(Int_t i =0; i<10;i++)  { fComponents[i] =0.0;}
     
       
   }
index a49e60d..720c3b8 100755 (executable)
 #include "AliTPCMonitorMappingHandler.h"
 #include "TH1.h"
 #include "TLegend.h"
+#include <TMath.h>
 #include "AliLog.h"
 #include <Riostream.h>
+#include <string>
 
 ClassImp(AliTPCMonitorMappingHandler)
 
@@ -267,22 +269,38 @@ void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
 
 
   Short_t*  mappingRow; 
-  char readcarry[255];
+//   char readcarry[255];
   Int_t version = -1;
   Int_t actPos  = 0;
   Int_t oldPos  = 0;
 
   ifstream *in = new ifstream();
   in->open(mapfile);
-  *in >> readcarry;
-  version = atoi(readcarry);
+
+  if (!in->is_open()) return;
+
+//   int numLines = 0;
+//   while ( std::getline(*in, std::string()) )
+//     ++numLines;
+//  in->seekg(0,ios::beg);
   
-  *in >> readcarry;
-  fnumofChannels = atoi(readcarry);
-  *in >> readcarry;
-  fmaxHWAdress = atoi(readcarry);
+//   *in >> readcarry;
+//   version = atoi(readcarry);
+  *in >> version;
+//   --numLines;
+//   *in >> readcarry;
+//   fnumofChannels = atoi(readcarry);
+  *in >> fnumofChannels;
+//   --numLines;
+  
+//   *in >> readcarry;
+//   fmaxHWAdress = atoi(readcarry);
+  *in >> fmaxHWAdress;
   fsizeofArray = fmaxHWAdress;
-       
+//   --numLines;
+  
+//   fnumofChannels=TMath::Min(fnumofChannels,numLines);
+  
   Short_t *fmappingEmptyRow = new Short_t[11];
   for(Int_t i = 0; i < 11 ; i++) {
     fmappingEmptyRow[i] = 0;
@@ -291,8 +309,9 @@ void AliTPCMonitorMappingHandler::ReadMapping(char* mapfile)
   for(Int_t i = 0; i < fnumofChannels ; i++) {
     mappingRow = new Short_t[11];
     for(Int_t j = 0 ; j < 11 ; j++) {
-      *in >> readcarry;
-      mappingRow[j] = atoi(readcarry);
+//       *in >> readcarry;
+//       mappingRow[j] = atoi(readcarry);
+      *in >> mappingRow[j];
     }
     actPos = mappingRow[0];
     fmapping[actPos] = mappingRow;