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

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
Branch
BackportPR10498
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 5360
Build 8782: Bitcoin ABC Buildbot (legacy)
Build 8781: arc lint + arc unit

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

src/net.cpp
2096

~6 changes missing from this file

src/netaddress.cpp
520

2 missing from this file

src/qt/coincontroldialog.cpp
470

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.
src/net.cpp
2096

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

src/netaddress.cpp
520

Deadalnix got one of them here: https://reviews.bitcoinabc.org/D1875. 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.