Page MenuHomePhabricator

remove unnecessary casts, use braced initialization and add an assertion
ClosedPublic

Authored by PiRK on Nov 9 2022, 06:40.

Details

Summary

This is a partial backport of core#22677, core#23649 and core#23683

https://github.com/bitcoin/bitcoin/pull/22677/commits/bedf246f1e2497a3641093c6e8fa11fb34dddac4
https://github.com/bitcoin/bitcoin/pull/23649/commits/b01784f0270dc20f8076ea4e46203c97b40b93ef
https://github.com/bitcoin/bitcoin/pull/23683/commits/b4adc5ad6769e4a5a6179dfff271cd4c9dc47a5b

Note that core#23683 mostly reverts the commit from core#22677. The remaining diff after applying both commits consists of just an additional assertion and comment.

Also note that core#23683 was applied out of sequence to avoid introducing a bug. In the source material, the assertion is added to the code after a piece of it was moved to validation.cpp.

Depends on D12440

Test Plan

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Nov 9 2022, 06:40

Tail of the build log:

[361/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[362/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[363/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[364/524] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[365/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[366/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[367/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[368/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[369/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[370/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[371/524] Installing component secp256k1
-- Install configuration: "RelWithDebInfo"
-- Install component: "secp256k1"
-- Installing: /results/artifacts/lib/libsecp256k1.a
-- Installing: /results/artifacts/include/secp256k1.h
-- Installing: /results/artifacts/include/secp256k1_preallocated.h
-- Installing: /results/artifacts/include/secp256k1_recovery.h
-- Installing: /results/artifacts/include/secp256k1_schnorr.h
[372/524] Linking C executable src/secp256k1/ecmult-bench
[373/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[374/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[375/524] Linking C executable src/secp256k1/recover-bench
[376/524] Linking C executable src/secp256k1/sign-bench
[377/524] Linking C executable src/secp256k1/internal-bench
[378/524] Linking C executable src/secp256k1/verify-bench
[379/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[380/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/sqlite.cpp.o
[381/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[382/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[383/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[384/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[385/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
[386/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[387/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/options.cpp.o
[388/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[389/524] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[390/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[391/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
[392/524] Linking CXX static library src/libcommon.a
[393/524] Linking CXX static library src/libscript.a
[394/524] Linking CXX static library src/libbitcoinconsensus.a
[395/524] Linking CXX shared library src/libbitcoinconsensus.so.0.26.4
[396/524] Creating library symlink src/libbitcoinconsensus.so.0 src/libbitcoinconsensus.so
[397/524] Linking CXX executable src/bitcoin-cli
[398/524] Linking CXX executable src/bitcoin-tx
[399/524] Linking CXX static library src/wallet/libwallet.a
[400/524] Linking CXX static library src/wallet/libwallet-tool.a
[401/524] Linking CXX executable src/bitcoin-wallet
[402/524] Building CXX object src/CMakeFiles/server.dir/txmempool.cpp.o
FAILED: src/CMakeFiles/server.dir/txmempool.cpp.o 
/usr/bin/ccache /usr/bin/clang++ -DBOOST_AC_USE_STD_ATOMIC -DBOOST_ALL_NO_LIB -DBOOST_ATOMIC_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SP_USE_STD_ATOMIC -DBOOST_THREAD_DYN_LINK -DBUILD_BITCOIN_INTERNAL -DENABLE_AVX2 -DENABLE_SHANI -DENABLE_SSE41 -DHAVE_BUILD_INFO -DHAVE_CONFIG_H -DHAVE_CONSENSUS_LIB -DLEVELDB_ATOMIC_PRESENT -DLEVELDB_PLATFORM_POSIX -DOS_LINUX -I../../src/leveldb/helpers/memenv -I../../src/. -Isrc -I../../src/univalue/include -Isrc/crypto/.. -I../../src/secp256k1/include -I../../src/leveldb/include -isystem /usr/include/jemalloc -isystem /usr/include/miniupnpc -Werror -g -O2 -fPIC -fvisibility=hidden -fstack-protector-all -Wstack-protector -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wall -Wextra -Wformat -Wgnu -Wvla -Wcast-align -Wunused-parameter -Wmissing-braces -Wthread-safety -Wrange-loop-analysis -Wredundant-decls -Wunreachable-code-loop-increment -Wsign-compare -Wconditional-uninitialized -Wdocumentation -Wformat-security -Wredundant-move -Woverloaded-virtual -Wshadow -Wshadow-field -Wno-unused-parameter -Wno-implicit-fallthrough -pthread -std=gnu++17 -MD -MT src/CMakeFiles/server.dir/txmempool.cpp.o -MF src/CMakeFiles/server.dir/txmempool.cpp.o.d -o src/CMakeFiles/server.dir/txmempool.cpp.o -c ../../src/txmempool.cpp
../../src/txmempool.cpp:86:5: error: calling function 'AssertLockHeldInternal<AnnotatedMixin<std::recursive_mutex>>' requires holding mutex 'cs_main' exclusively [-Werror,-Wthread-safety-analysis]
    AssertLockHeld(cs_main);
    ^
../../src/./sync.h:96:28: note: expanded from macro 'AssertLockHeld'
#define AssertLockHeld(cs) AssertLockHeldInternal(#cs, __FILE__, __LINE__, &cs)
                           ^
1 error generated.
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang failed with exit code 1

Tail of the build log:

[352/524] Linking C executable src/secp256k1/sign-bench
[353/524] Linking C executable src/secp256k1/internal-bench
[354/524] Installing component secp256k1
-- Install configuration: "RelWithDebInfo"
-- Install component: "secp256k1"
-- Installing: /results/artifacts/lib/libsecp256k1.a
-- Installing: /results/artifacts/include/secp256k1.h
-- Installing: /results/artifacts/include/secp256k1_preallocated.h
-- Installing: /results/artifacts/include/secp256k1_recovery.h
-- Installing: /results/artifacts/include/secp256k1_schnorr.h
[355/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/logging.cpp.o
[356/524] Building CXX object src/CMakeFiles/server.dir/rpc/mining.cpp.o
[357/524] Building CXX object src/CMakeFiles/server.dir/rpc/avalanche.cpp.o
[358/524] Building CXX object src/CMakeFiles/server.dir/torcontrol.cpp.o
[359/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/str.cpp.o
[360/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/transaction_utils.cpp.o
[361/524] Building CXX object src/CMakeFiles/server.dir/txorphanage.cpp.o
[362/524] Building CXX object src/CMakeFiles/server.dir/rpc/net.cpp.o
[363/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/blockfilter.cpp.o
[364/524] Building CXX object src/CMakeFiles/bitcoin-cli.dir/bitcoin-cli.cpp.o
[365/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/mining.cpp.o
[366/524] Linking CXX executable src/bitcoin-cli
[367/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/coincontrol.cpp.o
[368/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/coinselection.cpp.o
[369/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/context.cpp.o
[370/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/crypter.cpp.o
[371/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/net.cpp.o
[372/524] Building CXX object src/CMakeFiles/server.dir/wallet/init.cpp.o
[373/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/db.cpp.o
[374/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/wallet.cpp.o
[375/524] Building CXX object src/CMakeFiles/bitcoin-tx.dir/bitcoin-tx.cpp.o
[376/524] Linking CXX executable src/bitcoin-tx
[377/524] Building CXX object src/CMakeFiles/server.dir/rpc/blockchain.cpp.o
[378/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/bdb.cpp.o
[379/524] Building CXX object src/wallet/CMakeFiles/wallet-tool.dir/wallettool.cpp.o
[380/524] Building CXX object src/test/CMakeFiles/testutil.dir/util/setup_common.cpp.o
[381/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletutil.cpp.o
[382/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/fees.cpp.o
[383/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/db.cpp.o
[384/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/dns.cpp.o
[385/524] Building CXX object src/CMakeFiles/server.dir/rpc/rawtransaction.cpp.o
[386/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/sqlite.cpp.o
[387/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/load.cpp.o
[388/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/options.cpp.o
[389/524] Building CXX object src/CMakeFiles/server.dir/net_processing.cpp.o
[390/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/salvage.cpp.o
[391/524] Building CXX object src/seeder/CMakeFiles/bitcoin-seeder.dir/main.cpp.o
[392/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/__/interfaces/wallet.cpp.o
[393/524] Building CXX object src/seeder/CMakeFiles/seeder-base.dir/bitcoin.cpp.o
[394/524] Building CXX object src/CMakeFiles/server.dir/validation.cpp.o
[395/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/scriptpubkeyman.cpp.o
[396/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcdump.cpp.o
[397/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/walletdb.cpp.o
[398/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/rpcwallet.cpp.o
[399/524] Building CXX object src/wallet/CMakeFiles/wallet.dir/wallet.cpp.o
[400/524] Linking CXX static library src/wallet/libwallet.a
[401/524] Linking CXX static library src/wallet/libwallet-tool.a
[402/524] Linking CXX executable src/bitcoin-wallet
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang failed with exit code 1
PiRK planned changes to this revision.Nov 9 2022, 09:16
This revision is now accepted and ready to land.Nov 9 2022, 14:38