Skip to content

[ALICE3] Fix casts - #18381

Merged
njacazio merged 1 commit into
AliceO2Group:masterfrom
vkucera:cast-ALICE3
Oct 21, 2026
Merged

njacazio merged 1 commit into
AliceO2Group:masterfrom
vkucera:cast-ALICE3

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)

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 github-actions Bot changed the title Fix casts [ALICE3] Fix casts Oct 21, 2026
@github-actions

Copy link
Copy Markdown

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

@vkucera
vkucera marked this pull request as ready for review October 21, 2026 16:33
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for cd97cf2 at 2026-10-21 19:21:

## 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 6 errors and 55 warnings.'
Found 6 errors and 55 warnings.
++ [[ 6 -gt 0 ]]
++ cat /sw/BUILD/60466a34791dbb545a6786ef32891aa35ba98210/O2Physics-code-check/errors.txt
ALICE3/TableProducer/alice3TrackingTranslator.cxx:133:91: error: std::move of the const variable 'filename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
ALICE3/TableProducer/alice3TrackingTranslator.cxx:133:112: error: std::move of the const variable 'treename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
ALICE3/TableProducer/alice3TrackingTranslator.cxx:210:88: error: std::move of the const variable 'filename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
ALICE3/TableProducer/alice3TrackingTranslator.cxx:210:109: error: std::move of the const variable 'treename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
ALICE3/TableProducer/alice3TrackingTranslator.cxx:322:87: error: std::move of the const variable 'filename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
ALICE3/TableProducer/alice3TrackingTranslator.cxx:322:108: error: std::move of the const variable 'treename' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg,-warnings-as-errors]
++ [[ 55 -gt 0 ]]
++ cat /sw/BUILD/60466a34791dbb545a6786ef32891aa35ba98210/O2Physics-code-check/warnings.txt
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:66:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:71:8: warning: constructor does not initialize these fields: pdgDatabase, ccdb [cppcoreguidelines-pro-type-member-init]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:161:27: warning: use starts_with instead of find [modernize-use-starts-ends-with]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:278:11: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:301:7: warning: 'axisZ' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:306:13: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:310:37: 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]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:311:13: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:315:34: 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]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:365:7: warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:372:7: warning: switching on non-enum value without default case may not cover all cases [bugprone-switch-missing-default-case]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:392:13: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:392:16: warning: variable 'y' is not initialized [cppcoreguidelines-init-variables]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:392:19: warning: variable 'z' is not initialized [cppcoreguidelines-init-variables]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:397:12: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:789:17: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:802:17: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:814:17: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:827:17: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:838:17: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:887:35: warning: statement should be inside braces [readability-braces-around-statements]
ALICE3/TableProducer/OTF/onTheFlyMidPid.cxx:919:9: warning: do not use 'else' after 'continue' [readability-else-after-return]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:77:74: 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]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:80:52: 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]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:86:56: 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]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:110:5: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:242:14: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
ALICE3/TableProducer/alice3HfSelector3Prong.cxx:270:25: warning: boolean expression can be simplified by DeMorgan's theorem [readability-simplify-boolean-expr]
[0 more errors; see full log]

Full log here.

@njacazio
njacazio merged commit cfd760e into AliceO2Group:master Oct 21, 2026
13 of 14 checks passed
@vkucera
vkucera deleted the cast-ALICE3 branch October 21, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants