From 5de13cafd95fc5deaeb709329c62f936504c9241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= <26327373+vkucera@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:03:47 +0200 Subject: [PATCH] Fix casts Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint). - Remove redundant casts. (`readability-redundant-casting`) - Remove `const_cast`. (`cppcoreguidelines-pro-type-const-cast`) - Replace C-style casts with `static_cast`. (`google-readability-casting`, cpplint: `readability/casting`) - Replace unsafe C-style casts with `dynamic_cast`. (`cppcoreguidelines-pro-type-cstyle-cast`) - Replace `static_cast` in downcasts with `dynamic_cast`. (`cppcoreguidelines-pro-type-static-cast-downcast`) - Replace `reinterpret_cast` with `static_cast` or `dynamic_cast`. (`cppcoreguidelines-pro-type-reinterpret-cast`) - Replace two-step casting through `void*` with `reinterpret_cast`. (`bugprone-casting-through-void`) --- Tools/KFparticle/qaKFEventTrack.cxx | 4 ++-- Tools/KFparticle/qaKFParticleLc.cxx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tools/KFparticle/qaKFEventTrack.cxx b/Tools/KFparticle/qaKFEventTrack.cxx index 7ff14e80c1c..6e026a08f4e 100644 --- a/Tools/KFparticle/qaKFEventTrack.cxx +++ b/Tools/KFparticle/qaKFEventTrack.cxx @@ -247,7 +247,7 @@ struct qaKFEventTrack { template void writeVarTree(const T1& /*kfpTrackPi*/, const T2& KFPion, const T2& KFPV, const T3& track, const int source, const int pVContrib, const int runNumber, const T4& collision) { - const double pseudoRndm = track.pt() * 1000. - (int64_t)(track.pt() * 1000); + const double pseudoRndm = track.pt() * 1000. - static_cast(track.pt() * 1000); if (pseudoRndm < d_DwnSmplFact) { if (writeTree) { /// Filling the tree @@ -629,7 +629,7 @@ struct qaKFEvent { if (!isSelectedCollision(collisionIndex)) { continue; } - timeColl = uint64_t((bc.globalBC() - bc0) * o2::constants::lhc::LHCBunchSpacingNS) + collisionIndex.collisionTime(); + timeColl = static_cast((bc.globalBC() - bc0) * o2::constants::lhc::LHCBunchSpacingNS) + collisionIndex.collisionTime(); writeVarTreeColl(collisionIndex, timeColl, bc.timestamp(), collisionIndex.collisionTime(), tfID); } } diff --git a/Tools/KFparticle/qaKFParticleLc.cxx b/Tools/KFparticle/qaKFParticleLc.cxx index eb7c68eeaa8..f9e5c11e4a6 100644 --- a/Tools/KFparticle/qaKFParticleLc.cxx +++ b/Tools/KFparticle/qaKFParticleLc.cxx @@ -416,7 +416,7 @@ struct qaKFParticleLc { float chi2geo = KFLc.GetChi2() / KFLc.GetNDF(); float normdecayLength = KFLc_PV.GetDecayLength() / KFLc_PV.GetErrDecayLength(); float chi2topo = KFLc_PV.GetChi2() / KFLc_PV.GetNDF(); - const double pseudoRndm = trackKa.pt() * 1000. - (int64_t)(trackKa.pt() * 1000); + const double pseudoRndm = trackKa.pt() * 1000. - static_cast(trackKa.pt() * 1000); if (pseudoRndm < d_DwnSmplFact) { /// Filling the D0 tree rowKFLc(runNumber,