]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Try to fix some more coverity defects
authorcblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Dec 2010 15:42:55 +0000 (15:42 +0000)
committercblume <cblume@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Dec 2010 15:42:55 +0000 (15:42 +0000)
TRD/AliTRDCalibViewer.cxx

index f31941ec2b34843f9d5613cdfbbbc6608f5c6f35..ba04d1418d6a15aeb7555f8c507bb438f157f892 100644 (file)
@@ -204,9 +204,9 @@ const char* AliTRDCalibViewer::AddAbbreviations(char* c, Bool_t printDrawCommand
    for (Int_t i = 0; i < nNorm; i++) {
       normLengths[i] = ((TObjString*)listOfNormalizationVariables->At(i))->String().Length();
    }
-   Int_t *varSort = new Int_t[nVariables];
+   Int_t *varSort = new Int_t[nVariables+1];
    TMath::Sort(nVariables, varLengths, varSort, kTRUE);
-   Int_t *normSort = new Int_t[nNorm];
+   Int_t *normSort = new Int_t[nNorm+1];
    TMath::Sort(nNorm, normLengths, normSort, kTRUE);
       
    for (Int_t ivar = 0; ivar < nVariables; ivar++) {
@@ -360,7 +360,25 @@ void AliTRDCalibViewer::GetLayerSectorStack(TString trdString, Int_t& layerNo, I
   // encoded with the following format:
   // Layer%dSector%dStack%d
 
-  sscanf(trdString.Data(), "Layer%1dSector%02dStack%1d", &layerNo, &sectorNo, &stackNo);
+  //sscanf(trdString.Data(), "Layer%1dSector%02dStack%1d", &layerNo, &sectorNo, &stackNo);
+
+  // Coverity compliant solution (bit more cumbersome, but works) CBL
+  TString cName = trdString.Data();
+  Char_t  cLayer[2];
+  Char_t  cSector[3];
+  Char_t  cStack[2];
+
+  cLayer[0]  = cName[5];
+  cLayer[1]  = 0;
+  cSector[0] = cName[12];
+  cSector[1] = cName[13];
+  cSector[2] = 0;
+  cStack[0]  = cName[19];
+  cStack[1]  = 0;
+
+  layerNo    = atoi(cLayer);
+  sectorNo   = atoi(cSector);
+  stackNo    = atoi(cStack);
 
   return;
 }