From 003e9909bf68ab31e9f8cb7aed024619af5a96fc Mon Sep 17 00:00:00 2001 From: rgrosso Date: Tue, 25 Feb 2014 09:52:53 +0100 Subject: [PATCH] Coverity fix 22569 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 | 14 ++++++++------ STEER/CDB/AliCDBManager.cxx | 5 +---- STEER/CDB/AliCDBManager.h | 1 + STEER/CDB/AliCDBStorage.cxx | 16 ++++++++++++---- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/STEER/CDB/AliCDBLocal.cxx b/STEER/CDB/AliCDBLocal.cxx index 683ac1f072c..ab95c9cc8ca 100644 --- a/STEER/CDB/AliCDBLocal.cxx +++ b/STEER/CDB/AliCDBLocal.cxx @@ -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 (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 (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)) { diff --git a/STEER/CDB/AliCDBManager.cxx b/STEER/CDB/AliCDBManager.cxx index f1377456c1c..a8067a35ee8 100644 --- a/STEER/CDB/AliCDBManager.cxx +++ b/STEER/CDB/AliCDBManager.cxx @@ -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..."); diff --git a/STEER/CDB/AliCDBManager.h b/STEER/CDB/AliCDBManager.h index 6b3f9b7c9e9..36f4d53b058 100644 --- a/STEER/CDB/AliCDBManager.h +++ b/STEER/CDB/AliCDBManager.h @@ -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; diff --git a/STEER/CDB/AliCDBStorage.cxx b/STEER/CDB/AliCDBStorage.cxx index 85426f56fd3..64073629c7d 100644 --- a/STEER/CDB/AliCDBStorage.cxx +++ b/STEER/CDB/AliCDBStorage.cxx @@ -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.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 (md->Clone()); QueryValidFiles(); - AliInfo(Form("%d valid files found!", fValidFileIds.GetEntriesFast())); + AliInfo(Form("%d valid files found!", fValidFileIds.GetEntries())); } -- 2.43.0