Skip to content

[Trigger,PWGHF,PWGJE,PWGUD] Fix casts - #18384

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

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

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, ⚠️ 200 warnings, 🔕 0 disabled

@github-actions github-actions Bot changed the title Fix casts [Trigger,PWGHF,PWGJE,PWGUD] Fix casts Oct 21, 2026
@vkucera
vkucera marked this pull request as ready for review October 21, 2026 16:44
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for cbff6e2 at 2026-10-21 22:14:

## 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 19 errors and 150 warnings.'
Found 19 errors and 150 warnings.
++ [[ 19 -gt 0 ]]
++ cat /sw/BUILD/2e8873744afaad64953dd8b3f3952e52348997f2/O2Physics-code-check/errors.txt
EventFiltering/macros/checkBCrangesSkimming.C:49:111: error: field 'bcEvSel' will be initialized after field 'triMask' [clang-diagnostic-reorder-ctor,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:50:155: error: field 'bcEvSel' will be initialized after field 'triMask' [clang-diagnostic-reorder-ctor,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:162:30: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:224:21: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:252:30: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:268:17: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:410:29: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:450:74: error: unused variable 'maxdeltaBCAO2D' [clang-diagnostic-unused-variable,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:450:93: error: unused variable 'maxdeltaBCEvSel' [clang-diagnostic-unused-variable,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:452:23: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:460:32: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:476:19: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:560:21: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkBCrangesSkimming.C:682:29: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkSkimming.C:90:21: error: comparison of integers of different signs: 'int' and 'size_type' (aka 'unsigned long') [clang-diagnostic-sign-compare,-warnings-as-errors]
EventFiltering/macros/checkSkimming.C:130:35: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
EventFiltering/macros/selectivityPlot.C:82:11: error: unused variable 'color' [clang-diagnostic-unused-variable,-warnings-as-errors]
EventFiltering/macros/uploadOTSobjects.C:68:5: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
EventFiltering/macros/uploadOTSobjects.C:140:11: error: Value stored to 'bcEnd' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
++ [[ 150 -gt 0 ]]
++ cat /sw/BUILD/2e8873744afaad64953dd8b3f3952e52348997f2/O2Physics-code-check/warnings.txt
EventFiltering/PWGHF/HFFilterHelpers.h:305:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:309:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:313:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:319:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:329:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:334:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:344:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:348:6: warning: variable 'vecBinsPt' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]
EventFiltering/PWGHF/HFFilterHelpers.h:348:38: 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]
EventFiltering/PWGHF/HFFilterHelpers.h:348:46: 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]
EventFiltering/PWGHF/HFFilterHelpers.h:350:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:353:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:365:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:370:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
EventFiltering/PWGHF/HFFilterHelpers.h:377:11: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
[0 more errors; see full log]

Full log here.

@vkucera
vkucera marked this pull request as draft October 21, 2026 23:27
@vkucera
vkucera force-pushed the cast-EventFiltering branch from cbff6e2 to 16f520e Compare October 22, 2026 15:32
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`)
@vkucera
vkucera force-pushed the cast-EventFiltering branch from 16f520e to b395529 Compare October 22, 2026 17:03
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