Fixing FORWARD_NULL defects reported by Coverity
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Nov 2010 18:00:39 +0000 (18:00 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 4 Nov 2010 18:00:39 +0000 (18:00 +0000)
(Diego)

MUON/AliMUONTriggerChamberEfficiency.cxx
MUON/AliMUONTriggerDisplay.cxx

index 9c1063d..08c38a3 100755 (executable)
@@ -242,7 +242,11 @@ AliMUONTriggerChamberEfficiency::FillFromList(Bool_t useMeanValues)
        histoName.ReplaceAll("Count","Eff");
        effGraph->SetName(histoName.Data());
        fEfficiencyObjects->AddAt(effGraph, index);
-       AliDebug(5,Form("Adding object %s (%s/%s) at index %i",effGraph->GetName(),histoNum->GetName(),histoDen->GetName(),index));
+
+       TString debugString = Form("Adding object %s",effGraph->GetName());
+       if ( histoDen ) debugString += Form(" (%s/%s)",histoNum->GetName(),histoDen->GetName());
+       debugString += Form(" index %i",index);
+       AliDebug(5,debugString.Data());
 
        if ( useMeanValues ){
          Int_t currChamber = ich + AliMpConstants::NofTrackingChambers();
index 2c4a78f..162fb22 100644 (file)
@@ -231,8 +231,14 @@ Bool_t AliMUONTriggerDisplay::InitOrDisplayTriggerInfo(TObject* inputObject, TH2
     }
     else {
       TGraph* inputGraph = dynamic_cast<TGraph*>(inputObject);
-      if ( inputGraph->GetN() == 0 ){
-       return kTRUE;
+      if ( inputGraph ) {
+        if ( inputGraph->GetN() == 0 ){
+         return kTRUE;
+        }
+      }  
+      else {
+        AliWarning("The object should inherit from TH1 or TGraph!");
+        return kFALSE;
       }
     }
   }
@@ -438,13 +444,12 @@ void AliMUONTriggerDisplay::FillBins(TObject* inputObject, TH2* displayHisto,
   /// Given the bin in inputHisto, search the corresponding bins
   /// in display histo and fill it.
   //
-  TString className = inputObject->ClassName();
   Int_t binY=0;
   Float_t binContent=0;
-  if ( className.Contains("TH") ) {
-    TH1* inputHisto = dynamic_cast<TH1*>(inputObject);
+  TH1* inputHisto = dynamic_cast<TH1*>(inputObject);
+  if ( inputHisto ) {
     Int_t binX = inputHisto->GetXaxis()->FindBin(iElement1);
-    if(className.Contains("TH2")) {
+    if ( inputObject->IsA()->InheritsFrom("TH2") ) {
       binY = inputHisto->GetYaxis()->FindBin(iElement2);
       binContent = inputHisto->GetBinContent(binX, binY);
     }
@@ -452,15 +457,18 @@ void AliMUONTriggerDisplay::FillBins(TObject* inputObject, TH2* displayHisto,
   }
   else {
     TGraph* inputGraph = dynamic_cast<TGraph*>(inputObject);
-    Double_t xpt, ypt;
-    for ( Int_t ipt=0; ipt<inputGraph->GetN(); ipt++){
-      inputGraph->GetPoint(ipt, xpt, ypt);
-      if ( TMath::Abs(xpt - iElement1) < 0.1 ) {
-       binContent = ypt;
-       break;
+    if ( inputGraph ) {
+      Double_t xpt, ypt;
+      for ( Int_t ipt=0; ipt<inputGraph->GetN(); ipt++){
+        inputGraph->GetPoint(ipt, xpt, ypt);
+        if ( TMath::Abs(xpt - iElement1) < 0.1 ) {
+         binContent = ypt;
+         break;
+        }
       }
     }
-  }
+    else return;
+  }  
 
   if(binContent==0) {
     if(displayOpt==kShowZeroes) binContent = 1e-5;