From d6cd7bce8fc84740fc00fea0732a5568897ff0f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:39:07 +0100 Subject: [PATCH] Fix Clang-Tidy errors Fixes errors from the `clang-*` Clang-Tidy categories. --- Common/Core/macros/testMetadataHelper.C | 11 +++++------ Common/Tools/Multiplicity/macros/runGlauberFit.C | 3 ++- Common/Tools/PID/handleParamBase.h | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Common/Core/macros/testMetadataHelper.C b/Common/Core/macros/testMetadataHelper.C index 12b29935455..bd8bef9cd8c 100644 --- a/Common/Core/macros/testMetadataHelper.C +++ b/Common/Core/macros/testMetadataHelper.C @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -39,8 +40,6 @@ #include #include -#include - // Taken from O2/Framework/AnalysisSupport/src/Plugin.cxx auto readMetadata(std::unique_ptr& currentFile) -> std::vector { @@ -62,7 +61,7 @@ auto readMetadata(std::unique_ptr& currentFile) -> std::vector(m->GetValue(obj)); std::string key = "aod-metadata-" + std::string(obj->GetName()); LOGP(info, "- {}: {} goes into key {}", obj->GetName(), objString->String().Data(), key); - char const* value = strdup(objString->String()); + const auto value = objString->String().Data(); results.push_back(o2::framework::ConfigParamSpec{key, o2::framework::VariantType::String, value, {"Metadata in AOD"}}); } return results; @@ -104,7 +103,7 @@ std::map buildMapForCommitHash(const std::string& hash) std::string lineOfO2VersionsWithHash; while (std::getline(infileO2Versions, lineOfO2Version)) { // Extract the tag - int stripSize = 4; + std::size_t stripSize = 4; std::string tag = lineOfO2Version.substr(lineOfO2Version.find("O2::") + stripSize); // Strip a trailing "-1" (some alienv entries append this) stripSize = 2; @@ -147,7 +146,7 @@ void populateCCDBWithCommitAvailability(const std::map& hasHa metadata["O2Version"] = entry.first; const std::string ccdbPath = "O2Version/CommitHash/" + commitHash; auto headers = api.retrieveHeaders(ccdbPath, metadata, -1); - if (headers.size() != 0) { + if (!headers.empty()) { LOG(info) << "Entry in CCDB already present for commit hash " << commitHash << ", skipping creation"; continue; } @@ -189,7 +188,7 @@ void testMetadataHelper(const std::string& aod = "/tmp/AO2D.root") // Check if the hash is in the software tag const std::string v = metadataInfo.getO2Version(); - if (hasHashMap.find(v) == hasHashMap.end()) { + if (!hasHashMap.contains(v)) { LOG(fatal) << "Software tag " << v << " not found in available O2 versions"; } if (hasHashMap.at(v)) { diff --git a/Common/Tools/Multiplicity/macros/runGlauberFit.C b/Common/Tools/Multiplicity/macros/runGlauberFit.C index ea4b33c8a48..f329b39794c 100644 --- a/Common/Tools/Multiplicity/macros/runGlauberFit.C +++ b/Common/Tools/Multiplicity/macros/runGlauberFit.C @@ -32,13 +32,14 @@ #include #include +#include //________________________________________________________________ Double_t FastIntegrate(TF1* f1, Double_t a, Double_t b, Int_t n = 5) { // Do fast integration with N sampling points const Int_t nc = n; - Double_t x[nc], y[nc]; + std::vector x(nc), y(nc); Double_t lWidth = (b - a) / (static_cast(n - 1)); for (Int_t ii = 0; ii < n; ii++) { x[ii] = a + (static_cast(ii)) * lWidth; diff --git a/Common/Tools/PID/handleParamBase.h b/Common/Tools/PID/handleParamBase.h index 2362696d1b4..d5e24d46f70 100644 --- a/Common/Tools/PID/handleParamBase.h +++ b/Common/Tools/PID/handleParamBase.h @@ -49,11 +49,11 @@ std::string timeStampToHReadble(time_t rawtime) if (rawtime < 0) { return std::string(" latest"); } - struct tm* dt = new tm(); + tm dt{}; char buffer[30]; rawtime /= 1000; - localtime_r(&rawtime, dt); - strftime(buffer, sizeof(buffer), "%H:%M %d-%m %Y", dt); + localtime_r(&rawtime, &dt); + strftime(buffer, sizeof(buffer), "%H:%M %d-%m %Y", &dt); return std::string(buffer); } @@ -154,9 +154,9 @@ void setupTimestamps(int64_t& timestamp, headers = api.retrieveHeaders(run_path, metadata, -1); - if (headers.count("STF") == 0) { + if (!headers.contains("STF")) { LOGF(warning, "Cannot find STF for run %d in path '%s'. Using SOR as fallback", runnumber, run_path.data()); - if (headers.count("SOR") == 0) { + if (!headers.contains("SOR")) { LOGF(fatal, "Cannot find SOR in path '%s'.", run_path.data()); } sor = atol(headers["SOR"].c_str()); @@ -164,9 +164,9 @@ void setupTimestamps(int64_t& timestamp, sor = atol(headers["STF"].c_str()); } - if (headers.count("ETF") == 0) { + if (!headers.contains("ETF")) { LOGF(warning, "Cannot find ETF for run %d in path '%s'. Using EOR as fallback", runnumber, run_path.data()); - if (headers.count("EOR") == 0) { + if (!headers.contains("EOR")) { LOGF(fatal, "Cannot find EOR in path '%s'.", run_path.data()); } eor = atol(headers["EOR"].c_str());