Skip to content

[PWGCF] Fix casts - #18385

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

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

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 pwgcf label Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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

@github-actions github-actions Bot changed the title Fix casts [PWGCF] Fix casts Oct 21, 2026
@vkucera
vkucera force-pushed the cast-PWGCF branch 3 times, most recently from 48120c2 to 3e0cf62 Compare October 26, 2026 14:33
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 commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator Author

Dear code owners, the PR is ready for review.

@alibuild

alibuild commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

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

## 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 97 errors and 4890 warnings.'
Found 97 errors and 4890 warnings.
++ [[ 97 -gt 0 ]]
++ cat /sw/BUILD/a3bfdab8cbf9dba25ca458ddb58a999f92381bc8/O2Physics-code-check/errors.txt
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:714:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:715:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:717:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:718:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:720:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:721:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:723:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:724:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:726:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:727:9: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/RobustFluctuationObservables.cxx:1160:7: error: Value stored to 'magneticField' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx:2330:7: error: Value stored to 'centrality' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGCF/EbyEFluctuations/Tasks/kaonIsospinFluctuations.cxx:2451:7: error: Value stored to 'centrality' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:109:64: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:118:64: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:134:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:134:68: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:137:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:137:68: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:141:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:141:68: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:144:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:144:68: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:151:84: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:151:105: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:159:84: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:159:105: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:169:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:169:58: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:175:37: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Core/FemtoUniversePairSHCentMultKt.h:175:58: error: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation,-warnings-as-errors]
PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx:633:7: error: Value stored to 'fillQA' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGCF/FemtoUniverse/Tasks/femtoUniversePairTaskTrackNucleus.cxx:666:7: error: Value stored to 'fillQA' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGCF/FemtoWorld/TableProducer/femtoWorldProducerReducedTask.cxx:19:1: error: included header LFStrangenessTables.h is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGCF/FemtoWorld/TableProducer/femtoWorldProducerReducedTask.cxx:21:1: error: included header trackUtilities.h is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGCF/FemtoWorld/TableProducer/femtoWorldProducerReducedTask.cxx:30:1: error: included header ASoAHelpers.h is not used directly [misc-include-cleaner,-warnings-as-errors]
[0 more errors; see full log]

Full log here.

@vkucera
vkucera enabled auto-merge (squash) November 5, 2026 20:30

@abilandz abilandz 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.

@vkucera : I approve these changes for what concerns code i am responsible for, but as we already discussed in a separate thread, please re-consider this habit of making interventations out-of-a-blue without any announcement in somebody's else code. Thanks for your understanding!

@vkucera

vkucera commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator Author

@vkucera : I approve these changes for what concerns code i am responsible for, but as we already discussed in a separate thread, please re-consider this habit of making interventations out-of-a-blue without any announcement in somebody's else code. Thanks for your understanding!

Hi @abilandz , thanks for the review and for the reminder.
Please note that I have a long list of existing errors that I have to fix in order to make the CI work as intended, i.e. to report only new errors. That means that more PRs like this are coming. Please let me know how you wish to be informed. Thanks.

@abilandz

abilandz commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@vkucera : I approve these changes for what concerns code i am responsible for, but as we already discussed in a separate thread, please re-consider this habit of making interventations out-of-a-blue without any announcement in somebody's else code. Thanks for your understanding!

Hi @abilandz , thanks for the review and for the reminder. Please note that I have a long list of existing errors that I have to fix in order to make the CI work as intended, i.e. to report only new errors. That means that more PRs like this are coming. Please let me know how you wish to be informed. Thanks.

@vkucera : Thanks for your reply and clarification! The problem with the current approach is that whoever is doing important code development right now, that development needs to stopped because of your PR, and then the corresponding merge conflicts need to be resolved manually. I doubt there is anybody who is keen on resolving merging conflicts regularly - I already posted some suggestions in the original discussion, no need to repeat 'em here.

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.

6 participants