Page MenuHomePhabricator

Use static_cast instead of C-style casts for non-fundamental types
ClosedPublic

Authored by nakihito on Apr 2 2019, 17:58.

Details

Reviewers
jasonbcox
deadalnix
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rABC256ef1e899be: Use static_cast instead of C-style casts for non-fundamental types
Summary

A C-style cast is equivalent to try casting in the following order:

  1. const_cast(...)
  2. static_cast(...)
  3. const_cast(static_cast(...))
  4. reinterpret_cast(...)
  5. const_cast(reinterpret_cast(...))

By using static_cast<T>(...) explicitly we avoid the possibility
of an unintentional and dangerous reinterpret_cast. Furthermore
static_cast<T>(...) allows for easier grepping of casts. Please enter the commit message for your changes. Lines starting

Backport of Core PR10498
https://github.com/bitcoin/bitcoin/pull/10498

Completes T555

Test Plan

make check
test_runner.py

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

nakihito created this revision.Apr 2 2019, 17:58
Owners added a reviewer: Restricted Owners Package.Apr 2 2019, 17:58
Herald added a reviewer: Restricted Project. · View Herald TranscriptApr 2 2019, 17:58
Herald added a subscriber: schancel. · View Herald Transcript
jasonbcox requested changes to this revision.Apr 2 2019, 18:22

Note for other reviewers: netbase.cpp change was already done by Amaury

src/net.cpp
2096 ↗(On Diff #7913)

~6 changes missing from this file

src/netaddress.cpp
520 ↗(On Diff #7913)

2 missing from this file

src/qt/coincontroldialog.cpp
470 ↗(On Diff #7913)

I was going to flag this, but it looks like this should have been cleaned up anyway. This is fine imo.

This revision now requires changes to proceed.Apr 2 2019, 18:22
nakihito marked 3 inline comments as done.Apr 2 2019, 18:49
nakihito added inline comments.
src/net.cpp
2096 ↗(On Diff #7913)

Looks like deadalnix got them here: https://reviews.bitcoinabc.org/D1863

src/netaddress.cpp
520 ↗(On Diff #7913)

Deadalnix got one of them here: https://reviews.bitcoinabc.org/D1875. The other is for a function that no longer exists.

jasonbcox accepted this revision.Apr 2 2019, 20:59
This revision is now accepted and ready to land.Apr 2 2019, 20:59
This revision was automatically updated to reflect the committed changes.