Page MenuHomePhabricator

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

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



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

Completes T555

Test Plan

make check

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable

Event Timeline

Owners added a reviewer: Restricted Owners Package.Apr 2 2019, 17:58
jasonbcox requested changes to this revision.Apr 2 2019, 18:22

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

2096 ↗(On Diff #7913)

~6 changes missing from this file

520 ↗(On Diff #7913)

2 missing from this file

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 added inline comments.
2096 ↗(On Diff #7913)

Looks like deadalnix got them here:

520 ↗(On Diff #7913)

Deadalnix got one of them here: The other is for a function that no longer exists.

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