Skip to content

[PWGHF] Fix casts - #18388

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

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

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 commented Oct 21, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the pwghf PWG-HF label Oct 21, 2026
@github-actions github-actions Bot changed the title Fix casts [PWGHF] Fix casts Oct 21, 2026
@vkucera
vkucera force-pushed the cast-PWGHF branch 2 times, most recently from 522f3c5 to a00d476 Compare October 21, 2026 17:46
@vkucera
vkucera marked this pull request as ready for review October 21, 2026 17:47
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for a00d476 at 2026-10-21 20:37:

## 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 38 errors and 237 warnings.'
Found 38 errors and 237 warnings.
++ [[ 38 -gt 0 ]]
++ cat /sw/BUILD/9006c5936cb09fc7071247a59f4b84471756a132/O2Physics-code-check/errors.txt
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:216:17: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:217:17: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:218:23: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:219:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:220:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:221:24: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:223:19: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/DhCorrelationExtraction.cxx:224:20: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:125:35: error: comparison of integers of different signs: 'size_type' (aka 'unsigned long') and 'const int' [clang-diagnostic-sign-compare,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:150:26: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:153:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:153:31: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:154:27: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:154:40: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:155:31: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:155:44: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:166:35: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:166:47: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:177:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:178:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:179:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:180:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:181:18: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:182:15: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:183:26: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:184:26: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:262:12: error: Value stored to 'fFit' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:262:12: error: unused variable 'fFit' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:268:14: error: Value stored to 'tpT' during its initialization is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGHF/HFC/Macros/FitCorrel.C:268:14: error: unused variable 'tpT' [clang-diagnostic-unused-variable,-warnings-as-errors]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:31:10: error: 'Pythia8/Pythia.h' file not found [clang-diagnostic-error]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:36:1: error: included header map is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:39:1: error: included header vector is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:163:75: error: the parameter 'inFileFonllBhad' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:163:149: error: the parameter 'inFileFonllPromptDzero' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
PWGHF/Macros/computeFonllPlusPythiaPredictions.C:163:185: error: the parameter 'inFileFonllPromptDplus' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param,-warnings-as-errors]
[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

Labels

pwghf PWG-HF

Development

Successfully merging this pull request may close these issues.

2 participants