diff options
author | fanquake <fanquake@gmail.com> | 2023-07-26 15:47:41 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-07-26 16:03:39 +0100 |
commit | f57e724a809feb139c5ae71c4db65635427e4802 (patch) | |
tree | 66590b095bd3eaa684891b0f8a5ef91cf43a36de /ci | |
parent | f033a981ed72ceab8133ccddc6d99cd0d4b2d707 (diff) | |
parent | fa9108f85afdc926fd6a8b96cc2acff7ca25d7a8 (diff) | |
download | bitcoin-f57e724a809feb139c5ae71c4db65635427e4802.tar.xz |
Merge bitcoin/bitcoin#28127: refactor: Remove C-style const-violating cast, Use reinterpret_cast
fa9108f85afdc926fd6a8b96cc2acff7ca25d7a8 refactor: Use reinterpret_cast where appropriate (MarcoFalke)
3333f950d49f13662842650ae76599a0dff052eb refactor: Avoid casting away constness (MarcoFalke)
fa6394dd10ae71755e46fd523dd43c2a1f2b832d refactor: Remove unused C-style casts (MarcoFalke)
Pull request description:
Using a C-style cast to convert pointer types to a byte-like pointer type has many issues:
* It may accidentally and silently throw away `const`.
* It forces reviewers to check that it doesn't accidentally throw away `const`.
For example, on current master a `const char*` is cast to `unsigned char*` (without `const`), see https://github.com/bitcoin/bitcoin/blob/d23fda05842ba4539b225bbab01b94df0060f697/src/span.h#L273 . This can lead to UB, and the only reason why it didn't lead to UB is because the return type added back the `const`. (Obviously this would break if the return type was deduced via `auto`)
Fix all issues by adding back the `const` and using `reinterpret_cast` where appropriate.
ACKs for top commit:
darosior:
re-utACK fa9108f85afdc926fd6a8b96cc2acff7ca25d7a8
hebasto:
re-ACK fa9108f85afdc926fd6a8b96cc2acff7ca25d7a8.
john-moffett:
ACK fa9108f85afdc926fd6a8b96cc2acff7ca25d7a8
Tree-SHA512: 87f6e4b574f9bd96d4e0f2a0631fd0a9dc6096e5d4f1b95042fe9f197afc2fe9a24e333aeb34fed11feefcdb184a238fe1ea5aff10d580bb18d76bfe48b76a10
Diffstat (limited to 'ci')
0 files changed, 0 insertions, 0 deletions