Fixes for Coverity warnings
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Dec 2010 11:03:18 +0000 (11:03 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Dec 2010 11:03:18 +0000 (11:03 +0000)
STEER/AliCheb3D.cxx
STEER/AliLHCData.cxx
STEER/AliLHCDipValT.h
STEER/AliRectMatrix.cxx
STEER/AliRefArray.cxx

index be8981b..1f0a6c2 100644 (file)
@@ -38,7 +38,7 @@ AliCheb3D::AliCheb3D() :
   fUsrMacro(0) 
 {
   for (int i=3;i--;) {
-    fBMin[i] = fBMax[i] = fBScale[i] = fBOffset[i] = 0;
+    fBMin[i] = fBMax[i] = fBScale[i] = fBOffset[i] = fArgsTmp[i] = 0;
     fNPoints[i] = 0;
     fGridOffs[i] = 0.;
   }
index 03d28eb..25fa968 100755 (executable)
@@ -49,9 +49,9 @@
 ClassImp(AliLHCData)\r
 \r
 const Char_t* AliLHCData::fgkDCSNames[] = {\r
-  "LHC_IntensityBeam%d_totalIntensity",\r
-  "LHC_BeamIntensityPerBunchBeam%d_averageBeamIntensity",\r
-  "LHC_BeamIntensityPerBunchBeam%d_Average_BunchIntensities",\r
+  "LHC_IntensityBeam%1d_totalIntensity",\r
+  "LHC_BeamIntensityPerBunchBeam%1d_averageBeamIntensity",\r
+  "LHC_BeamIntensityPerBunchBeam%1d_Average_BunchIntensities",\r
   //\r
   "LHC_LumAverageBRANB_4%c2_acqMode",\r
   "LHC_LumAverageBRANB_4%c2_meanLuminosity",\r
@@ -63,22 +63,22 @@ const Char_t* AliLHCData::fgkDCSNames[] = {
   "LHC_CirculatingBunchConfig_Beam%d",\r
   "LHC_FillNumber",\r
   //\r
-  "LHC_BunchLengthBeam%d_nBunches",\r
-  "LHC_BunchLengthBeam%d_bunchesLenghts",\r
-  "LHC_BunchLengthBeam%d_filledBuckets",\r
+  "LHC_BunchLengthBeam%1d_nBunches",\r
+  "LHC_BunchLengthBeam%1d_bunchesLenghts",\r
+  "LHC_BunchLengthBeam%1d_filledBuckets",\r
   //\r
   "LHC_RunControl_ActiveInjectionScheme",\r
   "LHC_RunControl_BetaStar",\r
   "LHC_RunControl_IP2_Xing_Murad",\r
   "LHC_RunControl_IP2_ALICE_Murad",\r
 \r
-  "LHC_BeamSizeBeam%d_acqMode",\r
-  "LHC_BeamSizeBeam%d_sigmaH",\r
-  "LHC_BeamSizeBeam%d_sigmaV",\r
-  "LHC_BeamSizeBeam%d_emittanceH",\r
-  "LHC_BeamSizeBeam%d_emittanceV",\r
-  "LHC_BeamSizeBeam%d_errorSigmaH",\r
-  "LHC_BeamSizeBeam%d_errorSigmaV",\r
+  "LHC_BeamSizeBeam%1d_acqMode",\r
+  "LHC_BeamSizeBeam%1d_sigmaH",\r
+  "LHC_BeamSizeBeam%1d_sigmaV",\r
+  "LHC_BeamSizeBeam%1d_emittanceH",\r
+  "LHC_BeamSizeBeam%1d_emittanceV",\r
+  "LHC_BeamSizeBeam%1d_errorSigmaH",\r
+  "LHC_BeamSizeBeam%1d_errorSigmaV",\r
   //\r
   "LHC_CollimatorPos_%s_lvdt_%s"\r
 };\r
@@ -146,37 +146,37 @@ Bool_t AliLHCData::FillData(double tmin, double tmax)
   //\r
   for (int ibm=0;ibm<2;ibm++) {\r
     //\r
-    sprintf(buff,fgkDCSNames[kBunchConf],ibm+1);         // ----- declared bunch configuration\r
+    snprintf(buff,99,fgkDCSNames[kBunchConf],ibm+1);         // ----- declared bunch configuration\r
     FillBunchConfig(fBunchConfDecl[ibm], buff);\r
     //\r
-    sprintf(buff,fgkDCSNames[kBunchLgtFillB],ibm+1);     // ----- measured bunch configuration\r
+    snprintf(buff,99,fgkDCSNames[kBunchLgtFillB],ibm+1);     // ----- measured bunch configuration\r
     FillBunchConfig(fBunchConfMeas[ibm], buff);\r
     //\r
-    sprintf(buff,fgkDCSNames[kBunchLgt],ibm+1);          // ----- measured bunch lenghts\r
+    snprintf(buff,99,fgkDCSNames[kBunchLgt],ibm+1);          // ----- measured bunch lenghts\r
     FillBunchInfo(fBunchLengths[ibm],buff,ibm,kFALSE);  \r
     //\r
-    sprintf(buff,fgkDCSNames[kIntBunchAv],ibm+1);        // ----- B-by-B intensities\r
+    snprintf(buff,99,fgkDCSNames[kIntBunchAv],ibm+1);        // ----- B-by-B intensities\r
     FillBunchInfo(fIntensPerBunch[ibm],buff,ibm,kTRUE);\r
     //\r
     //\r
-    sprintf(buff,fgkDCSNames[kIntTot],ibm+1);            // ----- total intensities for beam 1 and 2\r
+    snprintf(buff,99,fgkDCSNames[kIntTot],ibm+1);            // ----- total intensities for beam 1 and 2\r
     FillScalarRecord(fIntensTotal[ibm], buff);\r
     //\r
-    sprintf(buff,fgkDCSNames[kIntTotAv],ibm+1);          // ----- total intensities for beam 1 and 2 from B-by-B average\r
+    snprintf(buff,99,fgkDCSNames[kIntTotAv],ibm+1);          // ----- total intensities for beam 1 and 2 from B-by-B average\r
     FillScalarRecord(fIntensTotalAv[ibm], buff);\r
     //\r
-    sprintf(buff,fgkDCSNames[kBeamSzEmittH],ibm+1);      // ----- H emittance for beam 1 and 2 \r
+    snprintf(buff,99,fgkDCSNames[kBeamSzEmittH],ibm+1);      // ----- H emittance for beam 1 and 2 \r
     FillScalarRecord(fEmittanceH[ibm], buff);\r
     //\r
-    sprintf(buff,fgkDCSNames[kBeamSzEmittV],ibm+1);      // ----- V emittance for beam 1 and 2 \r
+    snprintf(buff,99,fgkDCSNames[kBeamSzEmittV],ibm+1);      // ----- V emittance for beam 1 and 2 \r
     FillScalarRecord(fEmittanceV[ibm], buff);\r
     //\r
-    sprintf(buff ,fgkDCSNames[kBeamSzSigH],   ibm+1);    // ----- H sigmas and errors for beam 1 and 2 \r
-    sprintf(buff1,fgkDCSNames[kBeamSzSigHErr],ibm+1);\r
+    snprintf(buff,99 ,fgkDCSNames[kBeamSzSigH],   ibm+1);    // ----- H sigmas and errors for beam 1 and 2 \r
+    snprintf(buff1,99,fgkDCSNames[kBeamSzSigHErr],ibm+1);\r
     FillScalarRecord(fBeamSigmaH[ibm], buff, buff1);\r
     //\r
-    sprintf(buff ,fgkDCSNames[kBeamSzSigV],   ibm+1);    // ----- V sigmas and errors for beam 1 and 2 \r
-    sprintf(buff1,fgkDCSNames[kBeamSzSigVErr],ibm+1);\r
+    snprintf(buff,99 ,fgkDCSNames[kBeamSzSigV],   ibm+1);    // ----- V sigmas and errors for beam 1 and 2 \r
+    snprintf(buff1,99,fgkDCSNames[kBeamSzSigVErr],ibm+1);\r
     FillScalarRecord(fBeamSigmaV[ibm], buff, buff1);\r
     //\r
   }\r
@@ -186,26 +186,26 @@ Bool_t AliLHCData::FillData(double tmin, double tmax)
   //\r
   for (int ilr=0;ilr<2;ilr++) {\r
     //\r
-    sprintf(buff ,fgkDCSNames[kLumBunch], ilr ? 'R':'L');       // ---- BC-by-BC luminosity at IP2 and its error\r
-    sprintf(buff1,fgkDCSNames[kLumBunchErr], ilr ? 'R':'L');\r
+    snprintf(buff,99 ,fgkDCSNames[kLumBunch], ilr ? 'R':'L');       // ---- BC-by-BC luminosity at IP2 and its error\r
+    snprintf(buff1,99,fgkDCSNames[kLumBunchErr], ilr ? 'R':'L');\r
     FillBCLuminosities(fLuminPerBC[ilr], buff, buff1, 0); // BRAN L uses beam2 as a reference, BRAN R - beam1\r
     //\r
-    sprintf(buff ,fgkDCSNames[kLumTot]   , ilr ? 'R':'L');       // ---- total luminosity at IP2 and its error\r
-    sprintf(buff1,fgkDCSNames[kLumTotErr], ilr ? 'R':'L');\r
+    snprintf(buff,99 ,fgkDCSNames[kLumTot]   , ilr ? 'R':'L');       // ---- total luminosity at IP2 and its error\r
+    snprintf(buff1,99,fgkDCSNames[kLumTotErr], ilr ? 'R':'L');\r
     FillScalarRecord(fLuminTotal[ilr], buff, buff1);\r
     //\r
-    sprintf(buff ,fgkDCSNames[kLumAcqMode], ilr ? 'R':'L');      // ---- luminosity acquisition mode\r
+    snprintf(buff,99 ,fgkDCSNames[kLumAcqMode], ilr ? 'R':'L');      // ---- luminosity acquisition mode\r
     FillAcqMode(fLuminAcqMode[ilr], buff);\r
     //\r
-    sprintf(buff, fgkDCSNames[kLumCrossAng]   , ilr ? 'R':'L');  //----- crossing angle at IP2 and its error\r
-    sprintf(buff1,fgkDCSNames[kLumCrossAngErr], ilr ? 'R':'L');\r
+    snprintf(buff,99, fgkDCSNames[kLumCrossAng]   , ilr ? 'R':'L');  //----- crossing angle at IP2 and its error\r
+    snprintf(buff1,99,fgkDCSNames[kLumCrossAngErr], ilr ? 'R':'L');\r
     FillScalarRecord(fCrossAngle[ilr], buff, buff1);\r
     //    \r
   }\r
   //\r
   for (int icl=0;icl<kNCollimators;icl++) {             // ----- collimators positions\r
     for (int jaw=0;jaw<kNJaws;jaw++) {\r
-      sprintf(buff,fgkDCSNames[kCollPos], fgkDCSColNames[icl],fgkDCSColJaws[jaw]);        \r
+      snprintf(buff,99,fgkDCSNames[kCollPos], fgkDCSColNames[icl],fgkDCSColJaws[jaw]);        \r
       FillScalarRecord(fCollimators[icl][jaw], buff);\r
     } // jaws\r
   } // collimators\r
index c6ebfbe..439d9ea 100755 (executable)
@@ -117,7 +117,7 @@ Char_t* AliLHCDipValT<Element>::TimeAsString(double t, Bool_t utc)
   static char buff[22];
   time_t tt = (time_t) t;
   struct tm *time = utc ? gmtime(&tt) : localtime(&tt);
-  sprintf(buff,"%02d:%02d:%02d %02d/%02d/%04d",time->tm_hour,time->tm_min,time->tm_sec,
+  snprintf(buff,21,"%02d:%02d:%02d %02d/%02d/%04d",time->tm_hour,time->tm_min,time->tm_sec,
          time->tm_mday,time->tm_mon+1,time->tm_year+1900);
   return (char*)buff;
 }
index 3490912..b00aa77 100644 (file)
@@ -27,6 +27,7 @@ AliRectMatrix::AliRectMatrix(Int_t nrow,Int_t ncol)
 AliRectMatrix::AliRectMatrix(const AliRectMatrix &src)
   : TObject(src),fNRows(src.fNRows), fNCols(src.fNCols), fRows(0)
 {
+  fRows = new Double_t*[fNRows];
   for (int i=fNRows;i--;) {
     fRows[i] = new Double_t[fNCols];
     memcpy(fRows[i], src.fRows[i], fNCols*sizeof(Double_t));
index f2bff24..4318e11 100644 (file)
@@ -126,7 +126,7 @@ void AliRefArray::ExpandReferences(Int_t addSize)
   UInt_t*   buff = new UInt_t[fRefSize];
   UInt_t*   ind  = new UInt_t[fRefSize];
   memcpy(buff, fRefBuff, oldSize*sizeof(UInt_t)); // copy current content
-  memcpy(ind,  fRefInd,  oldSize*sizeof(UInt_t));
+  if (fRefInd) memcpy(ind,  fRefInd,  oldSize*sizeof(UInt_t));
   memset(buff+oldSize,0,(fRefSize-oldSize)*sizeof(UInt_t));
   memset(ind +oldSize,0,(fRefSize-oldSize)*sizeof(UInt_t));
   delete[] fRefBuff; fRefBuff = buff;