Skip to content

[PWGDQ] Fix casts - #18386

Merged
iarsene merged 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGDQ
Nov 2, 2026
Merged

iarsene merged 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGDQ

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 github-actions Bot added the pwgdq label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

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

alibuild commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for 42b4d95 at 2026-10-21 22:50:

No log files found

Full log here.

@mguilbau mguilbau left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vkucera,
Thanks a lot for this. That is a large clean-up of the DQ code. Nevertheless, I see you have move all our reinterpreted_cast to dynamic_cast. While I do understand the reasoning behind this, I recall (I was not DQ convener at that time) that this was attempted and we ended up in situation where the code was to slow and Table Maker was hitting some limits on HY.

@iarsene do you recall something of that sort? I might be mistaken

@vkucera
vkucera marked this pull request as draft October 21, 2026 23:06
@vkucera

vkucera commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

Hi @vkucera, Thanks a lot for this. That is a large clean-up of the DQ code. Nevertheless, I see you have move all our reinterpreted_cast to dynamic_cast. While I do understand the reasoning behind this, I recall (I was not DQ convener at that time) that this was attempted and we ended up in situation where the code was to slow and Table Maker was hitting some limits on HY.

@iarsene do you recall something of that sort? I might be mistaken

Hi @mguilbau , thanks for the feedback. I could use static_cast instead but then it's up to the author to verify that the cast is valid.

@vkucera
vkucera force-pushed the cast-PWGDQ branch 3 times, most recently from 2532b27 to 63796cf Compare October 26, 2026 14:33
@vkucera

vkucera commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator Author

@mguilbau @iarsene How do you wish to proceed?

@vkucera

vkucera commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

@mguilbau @iarsene How do you wish to proceed?

@mguilbau @iarsene Ping

@vkucera
vkucera marked this pull request as ready for review October 30, 2026 11:15
@vkucera
vkucera marked this pull request as draft October 30, 2026 11:16
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`)
@iarsene
iarsene marked this pull request as ready for review November 2, 2026 14:05
@iarsene
iarsene enabled auto-merge (squash) November 2, 2026 14:06
@alibuild

alibuild commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for cf64936 at 2026-11-02 15:36:

## 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 8 errors and 609 warnings.'
Found 8 errors and 609 warnings.
++ [[ 8 -gt 0 ]]
++ cat /sw/BUILD/66d6b32f56ec08d45db4ac73e3edb32aa97a53f9/O2Physics-code-check/errors.txt
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:66:7: error: Value stored to 'nBinMinPt' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:66:7: error: unused variable 'nBinMinPt' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:86:15: error: unused variable 'hChNames' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:94:15: error: unused variable 'hStNames' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:281:22: error: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage,-warnings-as-errors]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:329:22: error: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage,-warnings-as-errors]
PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx:3478:15: error: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy,-warnings-as-errors]
PWGDQ/Tasks/muonGlobalAlignment.cxx:24:1: error: included header FwdTrackReAlignTables.h is not used directly [misc-include-cleaner,-warnings-as-errors]
++ [[ 609 -gt 0 ]]
++ cat /sw/BUILD/66d6b32f56ec08d45db4ac73e3edb32aa97a53f9/O2Physics-code-check/warnings.txt
PWGDQ/Core/CutsLibrary.cxx:3663:8: warning: do not use 'compare' to test equality of strings; use the string equality operator instead [readability-string-compare]
PWGDQ/Core/CutsLibrary.cxx:3663:8: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
PWGDQ/Core/CutsLibrary.cxx:7255:8: warning: do not use 'compare' to test equality of strings; use the string equality operator instead [readability-string-compare]
PWGDQ/Core/CutsLibrary.cxx:7255:8: warning: implicit conversion 'int' -> 'bool' [readability-implicit-bool-conversion]
PWGDQ/Core/CutsLibrary.cxx:7807:33: warning: use 'contains' to check for membership [readability-container-contains]
PWGDQ/Core/CutsLibrary.cxx:7837:35: warning: use 'contains' to check for membership [readability-container-contains]
PWGDQ/Core/CutsLibrary.cxx:7844:35: warning: use 'contains' to check for membership [readability-container-contains]
PWGDQ/Core/CutsLibrary.cxx:7855:35: warning: use 'contains' to check for membership [readability-container-contains]
PWGDQ/Core/CutsLibrary.cxx:8208:21: warning: redundant string initialization [readability-redundant-string-init]
PWGDQ/Core/CutsLibrary.cxx:8284:10: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
PWGDQ/Core/CutsLibrary.h:122:23: warning: function 'o2::aod::dqcuts::ParseJSONAnalysisCompositeCut' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
PWGDQ/Core/CutsLibrary.h:152:37: warning: function 'o2::aod::dqmlcuts::makeLabeledCutsMl' has a definition with different parameter names [readability-inconsistent-declaration-parameter-name]
PWGDQ/Core/VarManager.h:1258:10: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Core/VarManager.h:1259:10: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Core/VarManager.h:1675:10: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Core/VarManager.h:1679:10: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Core/VarManager.h:4747:14: 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]
PWGDQ/Core/VarManager.h:5480:7: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Core/VarManager.h:5483:33: 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]
PWGDQ/Core/VarManager.h:5484:33: 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]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:32:67: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:33:53: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:33:76: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:34:33: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:35:31: warning: do not declare C-style arrays, use 'std::array' instead [modernize-avoid-c-arrays]
PWGDQ/Macros/evalMchTrackingEfficiency.cxx:49:3: warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
[0 more errors; see full log]

Full log here.

@iarsene
iarsene merged commit fd3c7c2 into AliceO2Group:master Nov 2, 2026
13 of 15 checks passed
@vkucera
vkucera deleted the cast-PWGDQ branch November 2, 2026 15: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.

4 participants