Remove some c-style cast that raised warnings on clang due to change in
the alignment requirement. Using reinterpret_cast<>() will
prevent these warnings.
Details
- Reviewers
deadalnix - Group Reviewers
Restricted Project - Commits
- rSTAGINGdbff6fd85ee6: Fix Clang -Wcast-align warnings
rABCdbff6fd85ee6: Fix Clang -Wcast-align warnings
Using clang as a compiler:
make check
Ensure that there is no -Wcast-align warning from the compiler on the files that are updated in this diff
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
I'm not sure we won anything here. Sure it silenced the warning, but it doesn't looks like anything was done to actually address the problem, or make sure the compiler has the knowledge that there is no problem. As far as I can tell, the only thing that is achieved here is making the code more opaque to the static analyzer in the compiler, unless I am missing something ?
src/netbase.cpp | ||
---|---|---|
94 ↗ | (On Diff #6512) | It looks like you have useless () here |
src/test/cuckoocache_tests.cpp | ||
34 ↗ | (On Diff #6512) | For this one, if would probably be beneficial to change uint256 to use larger integers internally. |
You're not missing anything, this is a workaround to silent the warnings while being iso functional.
The reinterpret_castnot being handled by the analyzer is actually a "feature" to explicitly tell clang that you know what you're doing.
I will update the loops to use uint8_t * instead, but regarding the sockaddr* the API seems designed to use these casts ; this code looks pretty standard.
src/test/cuckoocache_tests.cpp | ||
---|---|---|
34 ↗ | (On Diff #6512) | I think it can be build on 32-bits chunks instead of 8-bit, but I need to check the impacts. This change will better suit another diff anyway. |
It seems like you should split the patch into a part that deal with ip addresses and use reinterpet_cast and a part that updates uint256 innards.
src/test/cuckoocache_tests.cpp | ||
---|---|---|
215 ↗ | (On Diff #6519) | Please don't make the code worse to silence a warning. |
src/netaddress.cpp | ||
---|---|---|
484 ↗ | (On Diff #6522) | I think you have extra set of () in there. |