]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Coverity fix 22569
authorrgrosso <Raffaele.Grosso@cern.ch>
Tue, 25 Feb 2014 08:52:53 +0000 (09:52 +0100)
committerrgrosso <Raffaele.Grosso@cern.ch>
Tue, 25 Feb 2014 18:45:25 +0000 (19:45 +0100)
Fixing AliCDBLocal::GetId (savannah 103973)

In addition, reverting for the moment the query to fValidFileIds
if not in the cvmfs case

STEER/CDB/AliCDBLocal.cxx
STEER/CDB/AliCDBManager.cxx
STEER/CDB/AliCDBManager.h
STEER/CDB/AliCDBStorage.cxx

index 683ac1f072c6b513e14552d60839e6c453f278cb..ab95c9cc8ca6d1ed387eccaaa169314d3ca373ad 100644 (file)
@@ -245,7 +245,8 @@ AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) {
   // look for filename matching query (called by GetEntryId)
 
   // if querying for fRun and not specifying a version, look in the fValidFileIds list
-  if(query.GetFirstRun() == fRun && !query.HasVersion()) {
+  if(!AliCDBManager::Instance()->GetCvmfsOcdbTag().IsNull() && query.GetFirstRun() == fRun && !query.HasVersion()) {
+  //if(query.GetFirstRun() == fRun && !query.HasVersion()) {
     // get id from fValidFileIds
     TIter iter(&fValidFileIds);
 
@@ -253,10 +254,13 @@ AliCDBId* AliCDBLocal::GetId(const AliCDBId& query) {
     AliCDBId* result=0;
 
     while((anIdPtr = dynamic_cast<AliCDBId*> (iter.Next()))){
-      if(anIdPtr->GetPath() != query.GetPath()) continue;
-      result = anIdPtr;
+      if(anIdPtr->GetPath() == query.GetPath()){
+        result = anIdPtr;
+        break;
+      }
     }
-    return result;
+    if (result)
+      return dynamic_cast<AliCDBId*> (result->Clone());
   }
 
   // otherwise browse in the local filesystem CDB storage
@@ -977,8 +981,6 @@ void AliCDBLocal::QueryValidCVMFSFiles(TString& cvmfsOcdbTag) {
   ifstream *file = new ifstream(runValidFile.Data());
   if (!*file) {
     AliFatal(Form("Error opening file \"%s\"!", runValidFile.Data()));
-    file->close();
-    delete file;
   }
   TString filepath;
   while (filepath.ReadLine(*file)) {
index f1377456c1c68ee43c98ae11e79b2c3ee493f719..a8067a35ee83231e0724856badbd259d46f55c21 100644 (file)
@@ -745,8 +745,6 @@ void AliCDBManager::SetDefaultStorageFromRun(Int_t run) {
     ifstream *file = new ifstream(inoutFile.Data());
     if (!*file) {
       AliFatal(Form("Error opening file \"%s\"!", inoutFile.Data()));
-      file->close();
-      delete file;
     }
     TString lhcPeriod;
     TObjArray* oStringsArray = 0;
@@ -849,7 +847,6 @@ void AliCDBManager::SetSpecificStorage(const char* calibType, const AliCDBParam*
     return;
   }
 
-
   AliCDBPath aPath(calibType);
   if(!aPath.IsValid()){
     AliError(Form("Not a valid path: %s", calibType));
@@ -1655,7 +1652,7 @@ void AliCDBManager::QueryCDB() {
       AliDebug(2,Form("Querying specific storage %s",aCalibType->GetName()));
       AliCDBStorage *aStorage = GetStorage(aPar);
       if(aStorage->GetType() == "alien" || aStorage->GetType() == "local"){
-        aStorage->QueryCDB(fRun,aCalibType->GetName());
+        aStorage->QueryCDB(fRun, aCalibType->GetName());
       } else {
         AliDebug(2,
             "Skipping query for valid files, it is used only in grid...");
index 6b3f9b7c9e9d8f1661e99c7f2fcc7898becfdad0..36f4d53b0589b98cfc0b1314ef8be0d917e43580 100644 (file)
@@ -132,6 +132,7 @@ class AliCDBManager: public TObject {
     Int_t GetStartRunLHCPeriod();
     Int_t GetEndRunLHCPeriod();
     TString GetLHCPeriod();
+    TString GetCvmfsOcdbTag() const {return fCvmfsOcdb;}
 
     Bool_t DiffObjects(const char *cdbFile1, const char *cdbFile2) const;
 
index 85426f56fd3b0548b173be62544069dedd43911c..64073629c7dd4ee3b28b5cf7a0d9f0488a12d69d 100644 (file)
@@ -436,16 +436,24 @@ void AliCDBStorage::QueryCDB(Int_t run, const char* pathFilter,
   AliInfo(Form("Querying files valid for run %d and path \"%s\" into CDB storage  \"%s://%s\"",
         fRun, pathFilter, fType.Data(), fBaseFolder.Data()));
 
-  // Clear fValidFileIds list (it cannot be filled twice!
-  AliDebug(2, "Clearing list of CDB Id's previously loaded");
-  fValidFileIds.Clear();
+  // In fValidFileIds, clear id for the same 3level path, if any
+  AliDebug(3, Form("Clearing list of CDB Id's previously loaded for path \"%s\"", pathFilter));
+  AliCDBPath filter(pathFilter);
+  for (Int_t i=0; i<fValidFileIds.GetEntries(); ++i) {
+    AliCDBId *rmMe = dynamic_cast<AliCDBId*>(fValidFileIds.At(i));
+    AliCDBPath rmPath = rmMe->GetAliCDBPath();
+    if (filter.Comprises(rmPath)) {
+      AliDebug(3,Form("Removing id \"%s\" matching: \"%s\"", rmPath.GetPath().Data(), pathFilter));
+      delete fValidFileIds.RemoveAt(i);
+    }
+  }
 
   if(fMetaDataFilter) {delete fMetaDataFilter; fMetaDataFilter=0;}
   if(md) fMetaDataFilter = dynamic_cast<AliCDBMetaData*> (md->Clone());
 
   QueryValidFiles();
 
-  AliInfo(Form("%d valid files found!", fValidFileIds.GetEntriesFast()));
+  AliInfo(Form("%d valid files found!", fValidFileIds.GetEntries()));
 
 }