Incorrect named args are source of bugs, like #22979.
To allow them being checked by clang-tidy
, use a format it can understand.
Incorrect named args are source of bugs, like #22979.
To allow them being checked by clang-tidy
, use a format it can understand.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
ScriptToUniv
, TxToUniv
etc to return the UniValue
instead of mutating a parameter/reference by mjdietzx)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Also, fix argument name for FastRandomContext.
-BEGIN VERIFY SCRIPT-
perl -0777 -pi -e 's:((\(|\{|,)(\n| )*)\/\* ?([^=* ]+) ?\*\/ ?:\1/*\4=*/:g' $( git ls-files ./src/test ./src/wallet/test )
-END VERIFY SCRIPT-
Setup clang-tidy:
0apt install clang-tidy bear clang
1./autogen.sh && ./configure --with-incompatible-bdb CC=clang CXX=clang++
2make clean && bear make -j $(nproc) # For bear 2.x
3make clean && bear -- make -j $(nproc) # For bear 3.x
Full test:
0( cd ./src/ && run-clang-tidy -j $(nproc) )
Diff test:
0git diff | ( cd ./src/ && clang-tidy-diff -p2 -j $(nproc) )
ACK fa00447442f22a24e5ca5fc538d0bf7bef575544
I independently recreated the changes done in this PR by:
0perl -0777 -pi -e 's:((\(|\{|,)(\n| )*)\/\* ?([^=* ]+) ?\*\/ ?:\1/*\4=*/:g' $( git ls-files ./src/test ./src/wallet/test ) src/test/crypto_tests.cpp src/test/util/setup_common.h
After that I compared the original PR and my recreation and I got the following diff:
0--- a/src/test/crypto_tests.cpp
1+++ b/src/test/crypto_tests.cpp
2@@ -574,10 +574,10 @@ BOOST_AUTO_TEST_CASE(hkdf_hmac_sha256_l32_tests)
3 {
4 // Use rfc5869 test vectors but truncated to 32 bytes (our implementation only support length 32)
5 TestHKDF_SHA256_32(
6- /*IKM=*/"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
7- /*salt=*/"000102030405060708090a0b0c",
8- /*info=*/"f0f1f2f3f4f5f6f7f8f9",
9- /* expected OKM */ "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
10+ /*ikm_hex=*/"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
11+ /*salt_hex=*/"000102030405060708090a0b0c",
12+ /*info_hex=*/"f0f1f2f3f4f5f6f7f8f9",
13+ /*okm_check_hex=*/"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
14 TestHKDF_SHA256_32(
15 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f",
16 "606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf",
17diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
18index b583ddb07..4f2ccb6eb 100644
19--- a/src/test/util/setup_common.h
20+++ b/src/test/util/setup_common.h
21@@ -56,7 +56,7 @@ void Seed(FastRandomContext& ctx);
22 static inline void SeedInsecureRand(SeedRand seed = SeedRand::SEED)
23 {
24 if (seed == SeedRand::ZEROS) {
25- g_insecure_rand_ctx = FastRandomContext(/*deterministic=*/true);
26+ g_insecure_rand_ctx = FastRandomContext(/*fDeterministic=*/true);
27 } else {
28 Seed(g_insecure_rand_ctx);
29 }
The diff indicates only the explicit name changes and not any functional difference. The new names are the names of the variable in the function definition.
I agree with these changes. Thanks for catching and correcting this, @MarcoFalke!
ACK https://github.com/bitcoin/bitcoin/pull/23546/commits/fa00447442f22a24e5ca5fc538d0bf7bef575544
Manually tested the scripted diff to verify the produce the same changes.
Though I am getting few errors in the full test like this
0$ ( cd ./src/ && run-clang-tidy -j $(nproc) )
13 warnings and 2 errors generated.
2Error while processing /home/raj/github-repo/bitcoin/src/test/bswap_tests.cpp.
3Suppressed 3 warnings (3 in non-user code).
4Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
5Found compiler error(s).
6clang-tidy-12 --use-color -p=/home/raj/github-repo/bitcoin /home/raj/github-repo/bitcoin/src/validation.cpp
7error: unknown argument: '-fstack-reuse=none' [clang-diagnostic-error]
8error: unsupported option '-fno-extended-identifiers' [clang-diagnostic-error]
And also quite a lot of warnings.
Am I doing clang-tidy
wrong?
error: unknown argument: ‘-fstack-reuse=none’ [clang-diagnostic-error]
Did you run configure with clang and cleared the compile_commands.json?
0rm compile_commands.json
1./autogen.sh && ./configure CC=clang CXX=clang++