Skip to content
Snippets Groups Projects
Commit c2338251 authored by scott snyder's avatar scott snyder Committed by scott snyder
Browse files

tauRecTools: Fix gcc11 compilation warnings.

Check result of dynamic_cast before dereferencing.
parent 6f6a97cd
No related branches found
No related tags found
No related merge requests found
...@@ -63,13 +63,15 @@ std::vector<TString> BDTHelper::parseString(const TString& str, const TString& d ...@@ -63,13 +63,15 @@ std::vector<TString> BDTHelper::parseString(const TString& str, const TString& d
// split the string with ",", and put them into a vector // split the string with ",", and put them into a vector
for(size_t i = 0; i < arraySize; ++i) { for(size_t i = 0; i < arraySize; ++i) {
TString var = dynamic_cast<TObjString*> (objList->At(i))->String(); if (auto str = dynamic_cast<TObjString*> (objList->At(i))) {
var.ReplaceAll(" ", ""); TString var = str->String();
if(var.Contains(":=")) { var.ReplaceAll(" ", "");
var=var(var.Index(":=")+2, var.Length()-var.Index(":=")-2); if(var.Contains(":=")) {
var=var(var.Index(":=")+2, var.Length()-var.Index(":=")-2);
}
if(0==var.Length()) continue;
parsedString.push_back(var);
} }
if(0==var.Length()) continue;
parsedString.push_back(var);
} }
delete objList; delete objList;
......
...@@ -92,9 +92,11 @@ std::vector<TString> tauRecTools::parseString(const TString& str, const TString& ...@@ -92,9 +92,11 @@ std::vector<TString> tauRecTools::parseString(const TString& str, const TString&
std::vector<TString> parsed_strings; std::vector<TString> parsed_strings;
TObjArray* varList_ar = str.Tokenize(delim); TObjArray* varList_ar = str.Tokenize(delim);
for(int i = 0; i != varList_ar->GetEntries(); ++i){ for(int i = 0; i != varList_ar->GetEntries(); ++i){
TString var = dynamic_cast<TObjString*> (varList_ar->At(i))->String(); if (auto tos = dynamic_cast<TObjString*> (varList_ar->At(i))) {
if(var.Length()==0) continue; TString var = tos->String();
parsed_strings.push_back(var); if(var.Length()==0) continue;
parsed_strings.push_back(var);
}
} }
delete varList_ar; delete varList_ar;
return parsed_strings; return parsed_strings;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment