removing minor defects reported by Coverity: pointer protection, dead code
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Feb 2011 22:14:17 +0000 (22:14 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 3 Feb 2011 22:14:17 +0000 (22:14 +0000)
HLT/rec/AliHLTEsdManagerImplementation.cxx

index ab4b386..a0506f2 100644 (file)
@@ -123,7 +123,7 @@ int AliHLTEsdManagerImplementation::WriteESD(const AliHLTUInt8_t* pBuffer, AliHL
                               AliHLTComponentDataType dt, AliESDEvent* tgtesd, int eventno)
 {
   // see header file for class documentation
-  if (!pBuffer && size<=0) return -EINVAL;
+  if (pBuffer==NULL || size<4) return -EINVAL;
   int iResult=0;
   AliHLTUInt32_t firstWord=*((AliHLTUInt32_t*)pBuffer);
   if (firstWord==size-sizeof(AliHLTUInt32_t)) {
@@ -249,11 +249,6 @@ TTree* AliHLTEsdManagerImplementation::EmbedIntoTree(AliESDEvent* pESD, const ch
     iResult=-ENOMEM;
   }
 
-  if (iResult<0) {
-    pTree->GetUserInfo()->Clear();
-    delete pTree;
-  }
-
   return pTree;
 }
 
@@ -320,9 +315,9 @@ int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pS
 
     fpFile=new TFile(fName, "RECREATE");
     fpTree=new TTree(fTreeName, "Tree with HLT ESD objects");
-    fpTree->SetDirectory(0);
     fpEsd=new AliESDEvent;
-    if (fpEsd) {
+    if (fpEsd && fpTree) {
+      fpTree->SetDirectory(0);
       fpEsd->CreateStdContent();
       *fpEsd=*pSrcESD;
       if (fpTree) {
@@ -387,6 +382,9 @@ int AliHLTEsdManagerImplementation::AliHLTEsdListEntry::WriteESD(AliESDEvent* pS
     }
   }
 
+  // FIXME: use auto_ptr for the tree and ESD event and add proper
+  // cleanup if something fails
+
   return iResult;
 }