Skip to content

[PWGLF,PWGMM] Fix casts - #18391

Draft
vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGMM
Draft

vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGMM

Conversation

@vkucera

@vkucera vkucera commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

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)

@github-actions

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 482 warnings, 🔕 0 disabled

@github-actions github-actions Bot changed the title Fix casts [PWGLF,PWGMM] Fix casts Oct 21, 2026
@vkucera
vkucera marked this pull request as ready for review October 21, 2026 16:51
@alibuild

alibuild commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for d5ee002 at 2026-10-22 01:29:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 24 errors and 281 warnings.'
Found 24 errors and 281 warnings.
++ [[ 24 -gt 0 ]]
++ cat /sw/BUILD/e0cd49d9d3bfada8202aeeee683ae450413973a2/O2Physics-code-check/errors.txt
PWGMM/Lumi/Tasks/lumiStability.cxx:280:7: error: Value stored to 'nOrbitsPerTF' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:282:7: error: Value stored to 'nOrbitsPerTF' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:500:9: error: Value stored to 'deltaIndex' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:501:9: error: Value stored to 'deltaBC' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:648:11: error: Value stored to 'deltaIndex' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:649:11: error: Value stored to 'deltaBC' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:785:9: error: Value stored to 'deltaIndex' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/Tasks/lumiStability.cxx:786:9: error: Value stored to 'deltaBC' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/macros/merger.C:33:10: error: Value stored to 'list' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/macros/merger.C:33:10: error: unused variable 'list' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:18: error: parameter 'npar' is unused [misc-unused-parameters,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:18: error: unused parameter 'npar' [clang-diagnostic-unused-parameter,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:34: error: parameter 'gin' is unused [misc-unused-parameters,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:34: error: unused parameter 'gin' [clang-diagnostic-unused-parameter,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:73: error: parameter 'flag' is unused [misc-unused-parameters,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:48:73: error: unused parameter 'flag' [clang-diagnostic-unused-parameter,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:232:10: error: Value stored to 'fout' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Lumi/macros/non_fac.C:232:10: error: unused variable 'fout' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGMM/Mult/TableProducer/ambiguousTrackPropagation.cxx:295:7: error: Value stored to 'dcaInfo' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Mult/TableProducer/ambiguousTrackPropagation.cxx:378:7: error: Value stored to 'dcaInfo' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Mult/Tasks/dndeta-hi.cxx:822:11: error: Value stored to 'cent' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Mult/Tasks/dndeta-hi.cxx:825:11: error: Value stored to 'cent' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Mult/Tasks/dndeta-hi.cxx:835:14: error: Value stored to 'pTrack' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGMM/Mult/Tasks/dndeta-hi.cxx:836:14: error: Value stored to 'nTrack' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
++ [[ 281 -gt 0 ]]
++ cat /sw/BUILD/e0cd49d9d3bfada8202aeeee683ae450413973a2/O2Physics-code-check/warnings.txt
PWGMM/Lumi/Tasks/lumiStability.cxx:56:8: warning: constructor does not initialize these fields: ccdb, tsSOR, tsEOR [cppcoreguidelines-pro-type-member-init]
PWGMM/Lumi/Tasks/lumiStability.cxx:318:26: warning: statement should be inside braces [readability-braces-around-statements]
PWGMM/Lumi/Tasks/lumiStability.cxx:336:7: warning: use auto when initializing with a template cast to avoid duplicating the type name [modernize-use-auto]
PWGMM/Lumi/Tasks/lumiStability.cxx:348:26: warning: narrowing conversion from 'double' to 'int64_t' (aka 'long') [bugprone-narrowing-conversions]
PWGMM/Lumi/Tasks/lumiStability.cxx:349:26: warning: narrowing conversion from 'double' to 'int64_t' (aka 'long') [bugprone-narrowing-conversions]
PWGMM/Lumi/Tasks/lumiStability.cxx:365:35: warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]
PWGMM/Lumi/Tasks/lumiStability.cxx:366:35: warning: result of integer division used in a floating point context; possible loss of precision [bugprone-integer-division]
PWGMM/Lumi/Tasks/lumiStability.cxx:451:20: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGMM/Lumi/Tasks/lumiStability.cxx:452:20: warning: do not implicitly decay an array into a pointer; consider using gsl::array_view or an explicit cast instead [cppcoreguidelines-pro-bounds-array-to-pointer-decay]
PWGMM/Lumi/Tasks/lumiStability.cxx:503:38: warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]
[0 more errors; see full log]

Full log here.

@vkucera
vkucera marked this pull request as draft October 21, 2026 23:27
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`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants