Repository: bitcoin/bitcoin
File: src/test/fuzz/crypto.cpp (C++)

Code before:
        data.resize(fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096), fuzzed_data_provider.ConsumeIntegral<uint8_t>());
    }

    CHash160 hash160;
    CHash256 hash256;
    CHMAC_SHA256 hmac_sha256{data.data(), data.size()};
    CHMAC_SHA512 hmac_sha512{data.data(), data.size()};
    CRIPEMD160 ripemd160;
    CSHA1 sha1;
    CSHA256 sha256;
    CSHA512 sha512;
    SHA3_256 sha3;
    CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()};

    LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30)
    {
        CallOneOf(
            fuzzed_data_provider,
            [&] {
                if (fuzzed_data_provider.ConsumeBool()) {
                    data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
                    if (data.empty()) {
                        data.resize(fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096), fuzzed_data_provider.ConsumeIntegral<uint8_t>());
                    }
                }

                (void)hash160.Write(data);
                (void)hash256.Write(data);
                (void)hmac_sha256.Write(data.data(), data.size());
                (void)hmac_sha512.Write(data.data(), data.size());
                (void)ripemd160.Write(data.data(), data.size());
                (void)sha1.Write(data.data(), data.size());
                (void)sha256.Write(data.data(), data.size());
                (void)sha3.Write(data);
                (void)sha512.Write(data.data(), data.size());
                (void)sip_hasher.Write(data);

                (void)Hash(data);
                (void)Hash160(data);
                (void)sha512.Size();
            },
            [&] {
                (void)hash160.Reset();
                (void)hash256.Reset();
                (void)ripemd160.Reset();
                (void)sha1.Reset();
                (void)sha256.Reset();
                (void)sha3.Reset();
                (void)sha512.Reset();
            },
            [&] {

Review comment (performance):
Nit: use descriptive variable names for more clarity instead of single letters
<details>
  <summary>see diff</summary>
  
  ```diff
 diff --git a/src/test/fuzz/crypto.cpp b/src/test/fuzz/crypto.cpp
index aa478277e35..2fa2b109e55 100644
--- a/src/test/fuzz/crypto.cpp
+++ b/src/test/fuzz/crypto.cpp
@@ -23,8 +23,8 @@ FUZZ_TARGET(crypto)
     std::vector<uint8_t> data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
     if (data.empty()) {
         auto new_size = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096);
-        auto x = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
-        data.resize(new_size, x);
+        auto default_byte_value = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
+        data.resize(new_size, default_byte_value);
     }
 
     CHash160 hash160;
@@ -47,8 +47,8 @@ FUZZ_TARGET(crypto)
                     data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
                     if (data.empty()) {
                         auto new_size = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096);
-                        auto x = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
-                        data.resize(new_size, x);
+                        auto default_byte_value = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
+                        data.resize(new_size, default_byte_value);
                     }
                 }
 
diff --git a/src/test/fuzz/cuckoocache.cpp b/src/test/fuzz/cuckoocache.cpp
index f8a5bde3e6f..7fb7568c2bb 100644
--- a/src/test/fuzz/cuckoocache.cpp
+++ b/src/test/fuzz/cuckoocache.cpp
@@ -41,7 +41,7 @@ FUZZ_TARGET(cuckoocache)
         if (fuzzed_data_provider.ConsumeBool()) {
             cuckoo_cache.insert(fuzzed_data_provider.ConsumeBool());
         } else {
-            auto e = fuzzed_data_provider.ConsumeBool();
+            auto element = fuzzed_data_provider.ConsumeBool();
             auto erase = fuzzed_data_provider.ConsumeBool();
             cuckoo_cache.contains(e, erase);
         }
diff --git a/src/test/fuzz/prevector.cpp b/src/test/fuzz/prevector.cpp
index 76f2d31c4ec..42a2d409426 100644
--- a/src/test/fuzz/prevector.cpp
+++ b/src/test/fuzz/prevector.cpp
@@ -263,7 +263,7 @@ FUZZ_TARGET(prevector)
             test.clear();
             break;
         case 10: {
-            auto n = prov.ConsumeIntegralInRange<size_t>(0, 32767);
+            auto num_elements = prov.ConsumeIntegralInRange<size_t>(0, 32767);
             auto value = prov.ConsumeIntegral<int>();
             test.assign(n, value);
         } break;

   ```
</details>

Code after:
        auto new_size = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096);
        auto x = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
        data.resize(new_size, x);
    }

    CHash160 hash160;
    CHash256 hash256;
    CHMAC_SHA256 hmac_sha256{data.data(), data.size()};
    CHMAC_SHA512 hmac_sha512{data.data(), data.size()};
    CRIPEMD160 ripemd160;
    CSHA1 sha1;
    CSHA256 sha256;
    CSHA512 sha512;
    SHA3_256 sha3;
    CSipHasher sip_hasher{fuzzed_data_provider.ConsumeIntegral<uint64_t>(), fuzzed_data_provider.ConsumeIntegral<uint64_t>()};

    LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 30)
    {
        CallOneOf(
            fuzzed_data_provider,
            [&] {
                if (fuzzed_data_provider.ConsumeBool()) {
                    data = ConsumeRandomLengthByteVector(fuzzed_data_provider);
                    if (data.empty()) {
                        auto new_size = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 4096);
                        auto x = fuzzed_data_provider.ConsumeIntegral<uint8_t>();
                        data.resize(new_size, x);
                    }
                }

                (void)hash160.Write(data);
                (void)hash256.Write(data);
                (void)hmac_sha256.Write(data.data(), data.size());
                (void)hmac_sha512.Write(data.data(), data.size());
                (void)ripemd160.Write(data.data(), data.size());
                (void)sha1.Write(data.data(), data.size());
                (void)sha256.Write(data.data(), data.size());
                (void)sha3.Write(data);
                (void)sha512.Write(data.data(), data.size());
                (void)sip_hasher.Write(data);

                (void)Hash(data);
                (void)Hash160(data);
                (void)sha512.Size();
            },
            [&] {
                (void)hash160.Reset();
                (void)hash256.Reset();
                (void)ripemd160.Reset();
                (void)sha1.Reset();
                (void)sha256.Reset();