-
Notifications
You must be signed in to change notification settings - Fork 37.7k
scripted-diff: Use clang-tidy syntax for C++ named arguments (tests only) #23546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bff3f48
to
fabdf31
Compare
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
Concept ACK, thanks. |
fabdf31
to
fa8110a
Compare
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-
fa8110a
to
fa00447
Compare
Setup clang-tidy:
Full test:
Diff test:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa00447
I independently recreated the changes done in this PR by:
- Reseting the commit done in this PR and then,
- Using the following command.
perl -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:
--- a/src/test/crypto_tests.cpp
+++ b/src/test/crypto_tests.cpp
@@ -574,10 +574,10 @@ BOOST_AUTO_TEST_CASE(hkdf_hmac_sha256_l32_tests)
{
// Use rfc5869 test vectors but truncated to 32 bytes (our implementation only support length 32)
TestHKDF_SHA256_32(
- /*IKM=*/"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
- /*salt=*/"000102030405060708090a0b0c",
- /*info=*/"f0f1f2f3f4f5f6f7f8f9",
- /* expected OKM */ "3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
+ /*ikm_hex=*/"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
+ /*salt_hex=*/"000102030405060708090a0b0c",
+ /*info_hex=*/"f0f1f2f3f4f5f6f7f8f9",
+ /*okm_check_hex=*/"3cb25f25faacd57a90434f64d0362f2a2d2d0a90cf1a5a4c5db02d56ecc4c5bf");
TestHKDF_SHA256_32(
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f",
"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf",
diff --git a/src/test/util/setup_common.h b/src/test/util/setup_common.h
index b583ddb07..4f2ccb6eb 100644
--- a/src/test/util/setup_common.h
+++ b/src/test/util/setup_common.h
@@ -56,7 +56,7 @@ void Seed(FastRandomContext& ctx);
static inline void SeedInsecureRand(SeedRand seed = SeedRand::SEED)
{
if (seed == SeedRand::ZEROS) {
- g_insecure_rand_ctx = FastRandomContext(/*deterministic=*/true);
+ g_insecure_rand_ctx = FastRandomContext(/*fDeterministic=*/true);
} else {
Seed(g_insecure_rand_ctx);
}
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa00447
Manually tested the scripted diff to verify the produce the same changes.
Though I am getting few errors in the full test like this
$ ( cd ./src/ && run-clang-tidy -j $(nproc) )
3 warnings and 2 errors generated.
Error while processing /home/raj/github-repo/bitcoin/src/test/bswap_tests.cpp.
Suppressed 3 warnings (3 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
Found compiler error(s).
clang-tidy-12 --use-color -p=/home/raj/github-repo/bitcoin /home/raj/github-repo/bitcoin/src/validation.cpp
error: unknown argument: '-fstack-reuse=none' [clang-diagnostic-error]
error: unsupported option '-fno-extended-identifiers' [clang-diagnostic-error]
And also quite a lot of warnings.
Am I doing clang-tidy
wrong?
Did you run configure with clang and cleared the compile_commands.json?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa00447
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fa00447
… C++ named arguments (tests only) 6443c75 scripted-diff: Use clang-tidy syntax for C++ named arguments (MarcoFalke) 8859440 doc: Use clang-tidy comments in crypto_tests (MarcoFalke) Pull request description: Incorrect named args are source of bugs, like #22979. To allow them being checked by `clang-tidy`, use a format it can understand. ACKs for top commit: shaavan: ACK 6443c75 rajarshimaitra: ACK bitcoin/bitcoin@6443c75 jonatack: ACK 6443c75 fanquake: ACK 6443c75 Tree-SHA512: 4d23a8363da81dfea21a4cd8516ab5e0dc70119e4d503f3f240f38573218b2c2e84083b97e956c62942d78b2f17490f8b3b2e8077d257644fda1d901e2b80507
Incorrect named args are source of bugs, like #22979.
To allow them being checked by
clang-tidy
, use a format it can understand.