From 52cd9d6cb200fe463dbe9d8c6c404c4675b4b2fc Mon Sep 17 00:00:00 2001 From: Gerardo Ganis <Gerardo.Ganis@cern.ch> Date: Thu, 2 Sep 2010 11:42:26 +0000 Subject: [PATCH] Fix another bunch of issues found by coverity git-svn-id: http://root.cern.ch/svn/root/trunk@35121 27541ba8-7e3a-0410-8455-c3a389f83636 --- net/rpdutils/src/ssh.cxx | 3 +- proof/proof/src/TDSet.cxx | 13 ++--- proof/proof/src/TProof.cxx | 65 +------------------------ proof/proof/src/TProofServ.cxx | 3 +- proof/proof/src/TQueryResultManager.cxx | 9 +++- 5 files changed, 16 insertions(+), 77 deletions(-) diff --git a/net/rpdutils/src/ssh.cxx b/net/rpdutils/src/ssh.cxx index 9ca0da2b2ac..7af0e476a0f 100644 --- a/net/rpdutils/src/ssh.cxx +++ b/net/rpdutils/src/ssh.cxx @@ -215,7 +215,8 @@ int SshToolNotifyFailure(const char *Pipe) int sd; struct sockaddr_un servAddr; servAddr.sun_family = AF_UNIX; - strcpy(servAddr.sun_path, Pipe); + memcpy((void *) servAddr.sun_path, (void *) Pipe, 108); + servAddr.sun_path[107] = '\0'; if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { ErrorInfo("SshToolNotifyFailure: cannot open socket: exiting "); return 1; diff --git a/proof/proof/src/TDSet.cxx b/proof/proof/src/TDSet.cxx index a056ae60223..4c5f2d0e6db 100644 --- a/proof/proof/src/TDSet.cxx +++ b/proof/proof/src/TDSet.cxx @@ -723,7 +723,7 @@ TDSet::TDSet(const char *name, if (name && strlen(name) > 0) { // In the old constructor signature it was the 'type' if (!type) { - if ((c = TClass::GetClass(name))) + if (TClass::GetClass(name)) fType = name; else // Default type is 'TTree' @@ -733,12 +733,12 @@ TDSet::TDSet(const char *name, fName = name; // Check type if (strlen(type) > 0) - if ((c = TClass::GetClass(type))) + if (TClass::GetClass(type)) fType = type; } } else if (type && strlen(type) > 0) { // Check the type - if ((c = TClass::GetClass(type))) + if (TClass::GetClass(type)) fType = type; } // The correct class type @@ -1117,9 +1117,6 @@ Bool_t TDSet::Add(TFileInfo *fi, const char *meta) } TString msg; - // Element to be added - TDSetElement *el = 0; - // Check if a remap of the server coordinates is requested const char *file = fi->GetFirstUrl()->GetUrl(); Bool_t setLookedUp = kTRUE; @@ -1130,7 +1127,7 @@ Bool_t TDSet::Add(TFileInfo *fi, const char *meta) setLookedUp = kFALSE; } // Check if it already exists in the TDSet - if ((el = (TDSetElement *) fElements->FindObject(file))) { + if (fElements->FindObject(file)) { msg.Form("duplication detected: %40s is already in dataset - ignored", file); Warning("Add", "%s", msg.Data()); if (gProofServ) { @@ -1183,7 +1180,7 @@ Bool_t TDSet::Add(TFileInfo *fi, const char *meta) } const char *dataset = 0; if (strcmp(fi->GetTitle(), "TFileInfo")) dataset = fi->GetTitle(); - el = new TDSetElement(file, objname, dir, first, -1, 0, dataset); + TDSetElement *el = new TDSetElement(file, objname, dir, first, -1, 0, dataset); el->SetEntries(num); // Set looked-up bit diff --git a/proof/proof/src/TProof.cxx b/proof/proof/src/TProof.cxx index e5014508598..167f8f75d10 100644 --- a/proof/proof/src/TProof.cxx +++ b/proof/proof/src/TProof.cxx @@ -9691,14 +9691,6 @@ Bool_t TProof::RegisterDataSet(const char *dataSetName, return kFALSE; } - TSocket *master; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("RegisterDataSet", "No connection to the master!"); - return kFALSE; - } - TMessage mess(kPROOF_DATASETS); mess << Int_t(kRegisterDataSet); mess << TString(dataSetName); @@ -9767,14 +9759,6 @@ TMap *TProof::GetDataSets(const char *uri, const char* optStr) return 0; } - TSocket *master = 0; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("GetDataSets", "no connection to the master!"); - return 0; - } - TMessage mess(kPROOF_DATASETS); mess << Int_t(kGetDataSets); mess << TString(uri?uri:""); @@ -9810,15 +9794,6 @@ void TProof::ShowDataSets(const char *uri, const char* optStr) return; } - TSocket *master = 0; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("ShowDataSets", - "no connection to the master!"); - return; - } - TMessage mess(kPROOF_DATASETS); mess << Int_t(kShowDataSets); mess << TString(uri ? uri : ""); @@ -9914,15 +9889,7 @@ TFileCollection *TProof::GetDataSet(const char *uri, const char *optStr) Info("GetDataSet", "specifying a dataset name is mandatory"); return 0; } - - TSocket *master = 0; - - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("GetDataSet", "no connection to the master!"); - return 0; - } + TMessage nameMess(kPROOF_DATASETS); nameMess << Int_t(kGetDataSet); nameMess << TString(uri); @@ -9966,13 +9933,6 @@ Int_t TProof::RemoveDataSet(const char *uri, const char* optStr) // Remove the specified dataset from the PROOF cluster. // Files are not deleted. - TSocket *master; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("RemoveDataSet", "no connection to the master!"); - return kError; - } TMessage nameMess(kPROOF_DATASETS); nameMess << Int_t(kRemoveDataSet); nameMess << TString(uri?uri:""); @@ -10009,13 +9969,6 @@ Int_t TProof::VerifyDataSet(const char *uri, const char* optStr) } Int_t nMissingFiles = 0; - TSocket *master; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("VerifyDataSet", "no connection to the master!"); - return kError; - } TMessage nameMess(kPROOF_DATASETS); nameMess << Int_t(kVerifyDataSet); nameMess << TString(uri ? uri : ""); @@ -10042,14 +9995,6 @@ TMap *TProof::GetDataSetQuota(const char* optStr) return (TMap *)0; } - TSocket *master = 0; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("GetDataSetQuota", "no connection to the master!"); - return 0; - } - TMessage mess(kPROOF_DATASETS); mess << Int_t(kGetQuota); mess << TString(optStr?optStr:""); @@ -10089,14 +10034,6 @@ void TProof::ShowDataSetQuota(Option_t* opt) return; } - TSocket *master = 0; - if (fActiveSlaves->GetSize()) - master = ((TSlave*)(fActiveSlaves->First()))->GetSocket(); - else { - Error("ShowDataSetQuota", "no connection to the master!"); - return; - } - TMessage mess(kPROOF_DATASETS); mess << Int_t(kShowQuota); mess << TString(opt?opt:""); diff --git a/proof/proof/src/TProofServ.cxx b/proof/proof/src/TProofServ.cxx index 10163b4da86..3787b4dd2e0 100644 --- a/proof/proof/src/TProofServ.cxx +++ b/proof/proof/src/TProofServ.cxx @@ -3414,10 +3414,9 @@ void TProofServ::HandleProcess(TMessage *mess, TString *slb) if (elist) input->Add(elist); pq->SetInputList(input, kTRUE); - // Re-attach to the new list + // Clear the list input->Clear("nodelete"); SafeDelete(input); - input = pq->GetInputList(); // Save input data, if any TString emsg; diff --git a/proof/proof/src/TQueryResultManager.cxx b/proof/proof/src/TQueryResultManager.cxx index fbf8b25fb20..3858dbba4d1 100644 --- a/proof/proof/src/TQueryResultManager.cxx +++ b/proof/proof/src/TQueryResultManager.cxx @@ -17,6 +17,7 @@ // // ////////////////////////////////////////////////////////////////////////// +#include <errno.h> #ifdef WIN32 # include <io.h> #endif @@ -78,7 +79,11 @@ void TQueryResultManager::AddLogFile(TProofQueryResult *pq) fflush(fLogFile); // Save current position - off_t lnow = lseek(fileno(fLogFile), (off_t) 0, SEEK_CUR); + off_t lnow = 0; + if ((lnow = lseek(fileno(fLogFile), (off_t) 0, SEEK_CUR)) < 0) { + Error("AddLogFile", "problems lseeking current position on log file (errno: %d)", errno); + return; + } // The range we are interested in Int_t start = pq->fStartLog; @@ -95,7 +100,7 @@ void TQueryResultManager::AddLogFile(TProofQueryResult *pq) } // Restore initial position if partial send - lseek(fileno(fLogFile), lnow, SEEK_SET); + if (lnow >= 0) lseek(fileno(fLogFile), lnow, SEEK_SET); } //______________________________________________________________________________ Int_t TQueryResultManager::CleanupQueriesDir() -- GitLab