mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 12:22:39 -03:00
Merge bitcoin/bitcoin#24971: tidy: modernize-use-nullptr
9c96f1008b
tidy: enable modernize-use-nullptr (fanquake)e53274868e
Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) (practicalswift) Pull request description: Alternative to #15112 which uses `clang-tidy` to do perform the checking, rather than `-Wzero-as-null-pointer-constant`, and avoids having to uses pragmas, i.e: ```cpp #if defined(HAVE_CONFIG_H) #include <config/bitcoin-config.h> #endif #if defined(HAVE_W_ZERO_AS_NULL_POINTER_CONSTANT) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" #endif ``` to suppress warnings coming from upstream code. Can be tested by dropping the preceding commit. Should produce errors like: ```bash clang-tidy-14 --use-color -p=/home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp:678:36: error: use nullptr [modernize-use-nullptr,-warnings-as-errors] if (!Socks5(strDest, port, 0, sock)) { ^ nullptr ``` ACKs for top commit: laanwj: Concept and code review ACK9c96f1008b
Tree-SHA512: d822a354e44ba8f7fc53da9a4be7de5c25cc4ffc7c57651b76fdd1a030764b0390cfd79fca94685b8a3ff4f4d13054764f12d1f0d8c2a1b9ba519a7524f7f5bf
This commit is contained in:
commit
cc3877f831
12 changed files with 29 additions and 13 deletions
|
@ -49,7 +49,7 @@ if [[ ${USE_MEMORY_SANITIZER} == "true" ]]; then
|
|||
fi
|
||||
|
||||
if [[ "${RUN_TIDY}" == "true" ]]; then
|
||||
MAYBE_BEAR="bear"
|
||||
MAYBE_BEAR="bear --config src/.bear-tidy-config"
|
||||
MAYBE_TOKEN="--"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1935,6 +1935,7 @@ AC_CONFIG_LINKS([contrib/devtools/test-security-check.py:contrib/devtools/test-s
|
|||
AC_CONFIG_LINKS([contrib/devtools/test-symbol-check.py:contrib/devtools/test-symbol-check.py])
|
||||
AC_CONFIG_LINKS([contrib/filter-lcov.py:contrib/filter-lcov.py])
|
||||
AC_CONFIG_LINKS([contrib/macdeploy/background.tiff:contrib/macdeploy/background.tiff])
|
||||
AC_CONFIG_LINKS([src/.bear-tidy-config:src/.bear-tidy-config])
|
||||
AC_CONFIG_LINKS([src/.clang-tidy:src/.clang-tidy])
|
||||
AC_CONFIG_LINKS([test/functional/test_runner.py:test/functional/test_runner.py])
|
||||
AC_CONFIG_LINKS([test/fuzz/test_runner.py:test/fuzz/test_runner.py])
|
||||
|
|
15
src/.bear-tidy-config
Normal file
15
src/.bear-tidy-config
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"output": {
|
||||
"content": {
|
||||
"include_only_existing_source": true,
|
||||
"paths_to_include": [],
|
||||
"paths_to_exclude": [
|
||||
"src/leveldb"
|
||||
]
|
||||
},
|
||||
"format": {
|
||||
"command_as_array": true,
|
||||
"drop_output_field": false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +1,2 @@
|
|||
Checks: '-*,bugprone-argument-comment'
|
||||
WarningsAsErrors: bugprone-argument-comment
|
||||
Checks: '-*,bugprone-argument-comment,modernize-use-nullptr'
|
||||
WarningsAsErrors: 'bugprone-argument-comment,modernize-use-nullptr'
|
||||
|
|
|
@ -193,7 +193,7 @@ static bool ProcessUpnp()
|
|||
std::string strDesc = PACKAGE_NAME " " + FormatFullVersion();
|
||||
|
||||
do {
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
|
||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", nullptr, "0");
|
||||
|
||||
if (r != UPNPCOMMAND_SUCCESS) {
|
||||
ret = false;
|
||||
|
@ -206,7 +206,7 @@ static bool ProcessUpnp()
|
|||
} while (g_mapport_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD));
|
||||
g_mapport_interrupt.reset();
|
||||
|
||||
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
|
||||
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", nullptr);
|
||||
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);
|
||||
freeUPNPDevlist(devlist); devlist = nullptr;
|
||||
FreeUPNPUrls(&urls);
|
||||
|
|
|
@ -675,7 +675,7 @@ bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Socks5(strDest, port, 0, sock)) {
|
||||
if (!Socks5(strDest, port, nullptr, sock)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,7 +226,7 @@ bool Intro::showIfNeeded(bool& did_show_intro, int64_t& prune_MiB)
|
|||
}
|
||||
|
||||
/* If current default data directory does not exist, let the user choose one */
|
||||
Intro intro(0, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
|
||||
Intro intro(nullptr, Params().AssumedBlockchainSize(), Params().AssumedChainStateSize());
|
||||
intro.setDataDirectory(dataDir);
|
||||
intro.setWindowIcon(QIcon(":icons/bitcoin"));
|
||||
did_show_intro = true;
|
||||
|
|
|
@ -363,10 +363,10 @@ void RandAddStaticEnv(CSHA512& hasher)
|
|||
|
||||
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
|
||||
// Network interfaces
|
||||
struct ifaddrs *ifad = NULL;
|
||||
struct ifaddrs *ifad = nullptr;
|
||||
getifaddrs(&ifad);
|
||||
struct ifaddrs *ifit = ifad;
|
||||
while (ifit != NULL) {
|
||||
while (ifit != nullptr) {
|
||||
hasher.Write((const unsigned char*)&ifit, sizeof(ifit));
|
||||
hasher.Write((const unsigned char*)ifit->ifa_name, strlen(ifit->ifa_name) + 1);
|
||||
hasher.Write((const unsigned char*)&ifit->ifa_flags, sizeof(ifit->ifa_flags));
|
||||
|
|
|
@ -37,7 +37,7 @@ struct secure_allocator : public std::allocator<T> {
|
|||
typedef secure_allocator<_Other> other;
|
||||
};
|
||||
|
||||
T* allocate(std::size_t n, const void* hint = 0)
|
||||
T* allocate(std::size_t n, const void* hint = nullptr)
|
||||
{
|
||||
T* allocation = static_cast<T*>(LockedPoolManager::Instance().alloc(sizeof(T) * n));
|
||||
if (!allocation) {
|
||||
|
|
|
@ -128,7 +128,7 @@ void ECRYPT_encrypt_bytes(ECRYPT_ctx* x, const u8* m, u8* c, u32 bytes)
|
|||
{
|
||||
u32 x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15;
|
||||
u32 j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15;
|
||||
u8* ctarget = NULL;
|
||||
u8* ctarget = nullptr;
|
||||
u8 tmp[64];
|
||||
uint32_t i;
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ std::map<std::string,std::string> ParseTorReplyMapping(const std::string &s)
|
|||
|
||||
TorController::TorController(struct event_base* _base, const std::string& tor_control_center, const CService& target):
|
||||
base(_base),
|
||||
m_tor_control_center(tor_control_center), conn(base), reconnect(true), reconnect_ev(0),
|
||||
m_tor_control_center(tor_control_center), conn(base), reconnect(true), reconnect_ev(nullptr),
|
||||
reconnect_timeout(RECONNECT_TIMEOUT_START),
|
||||
m_target(target)
|
||||
{
|
||||
|
|
|
@ -2768,7 +2768,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
} else if (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS) {
|
||||
// Make it impossible to disable private keys after creation
|
||||
error = strprintf(_("Error loading %s: Private keys can only be disabled during creation"), walletFile);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
} else if (walletInstance->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
||||
for (auto spk_man : walletInstance->GetActiveScriptPubKeyMans()) {
|
||||
if (spk_man->HavePrivateKeys()) {
|
||||
|
|
Loading…
Reference in a new issue