refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o) #19373

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2020_06_hexstr changing 18 files +43 −43
  1. laanwj commented at 3:41 pm on June 24, 2020: member

    HexStr can be called with anything that bas begin() and end() functions, so clean up the redundant calls.

    (context: I tried to convert HexStr to use span, but this turns out to be somewhat more involved than I thought, because of the limitation to pre-c++17 Span lacking iterator-based constructor) . This commit is a first step which stands on its own though)

  2. laanwj added the label Refactoring on Jun 24, 2020
  3. jonatack commented at 4:25 pm on June 24, 2020: member

    Nice cleanup.

    almost-ACK 282df9029ff138ec1d263e57fcf3373d51929598 modulo when building the fuzzers

    0test/fuzz/decode_tx.cpp:17:39: error: no matching constructor for initialization of 'std::string' (aka 'basic_string<char>')
    1    const std::string tx_hex = HexStr(std::string{buffer});
    2                                      ^          ~~~~~~~~
    
  4. refactor: Replace HexStr(o.begin(), o.end()) with HexStr(o)
    HexStr can be called with anything that bas `begin()` and `end()` functions,
    so clean up the redundant calls.
    bd93e32292
  5. laanwj force-pushed on Jun 24, 2020
  6. laanwj commented at 4:42 pm on June 24, 2020: member
    Thanks! Re-pushed, hopefully fixing the fuzzer issue.
  7. jonatack commented at 5:01 pm on June 24, 2020: member

    ACK bd93e32292c96b671e71223032ff8f660ce27c5d

    git diff 282df90 bd93e32

    0diff --git a/src/test/fuzz/decode_tx.cpp b/src/test/fuzz/decode_tx.cpp
    1@@ -14,7 +14,7 @@
    2 
    3 void test_one_input(const std::vector<uint8_t>& buffer)
    4 {
    5-    const std::string tx_hex = HexStr(std::string{buffer});
    6+    const std::string tx_hex = HexStr(buffer);
    

    recalcitrant fuzzer is back in action

     0((HEAD detached at origin/pr/19373))$ ./src/test/fuzz/decode_tx ../qa-assets/fuzz_seed_corpus/
     1INFO: Seed: 4054234011
     2INFO: Loaded 1 modules   (20258 inline 8-bit counters): 20258 [0x5645f8a56df0, 0x5645f8a5bd12), 
     3INFO: Loaded 1 PC tables (20258 PCs): 20258 [0x5645f8a5bd18,0x5645f8aaaf38), 
     4INFO:    53252 files found in ../qa-assets/fuzz_seed_corpus/
     5INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
     6INFO: seed corpus: files: 53252 min: 1b max: 3984182b total: 495231715b rss: 100Mb
     7[#2](/bitcoin-bitcoin/2/)	pulse  ft: 693 exec/s: 0 rss: 102Mb
     8[#4](/bitcoin-bitcoin/4/)	pulse  cov: 692 ft: 693 corp: 1/1b exec/s: 0 rss: 102Mb
     9.../...
    10[#16384](/bitcoin-bitcoin/16384/)	pulse  cov: 2638 ft: 7052 corp: 158/4355b exec/s: 399 rss: 257Mb
    11[#32768](/bitcoin-bitcoin/32768/)	pulse  cov: 2646 ft: 10391 corp: 268/18Kb exec/s: 315 rss: 269Mb
    
  8. troygiorshev commented at 5:16 pm on June 24, 2020: contributor

    ACK bd93e32292c96b671e71223032ff8f660ce27c5d

    When running all of the fuzz tests, descriptor_parse and parse_univalue break for me. However, those aren’t touched by this PR so I’m assuming it’s a problem with my machine. When those are excluded, everything works fine.

    Looking forward to eventually being able to build the fuzz tests at the same time as everything else :)

  9. jonatack commented at 5:23 pm on June 24, 2020: member
    @troygiorshev maybe make clean or make distclean might help: ./autogen.sh ; ./configure --enable-c++17 --enable-fuzz --with-sanitizers=address,fuzzer,undefined CC=clang CXX=clang++ && make clean && make -j <nproc>
  10. MarcoFalke commented at 6:23 pm on June 24, 2020: member

    I ran sed -i --regexp-extended -e 's/HexStr\(([^(]+)\.begin\(\), *([^(]+)\.end\(\)\)/HexStr(\1)/g' $(git grep -l HexStr) and arrived at the same result.

    review ACK bd93e32292c96b671e71223032ff8f660ce27c5d 🔌

    Signature:

     0-----BEGIN PGP SIGNED MESSAGE-----
     1Hash: SHA512
     2
     3review ACK bd93e32292c96b671e71223032ff8f660ce27c5d 🔌
     4-----BEGIN PGP SIGNATURE-----
     5
     6iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
     7pUgRIAv/Uk2ihLCqBuVZ0KblTbUu+g5OGfsCXD9KS2QFTVWWMoa7uNFfJW1AQfVq
     8xwu1u7fHAxE51Pd8pshRLD7PjNRT1vab5wW5NXp0UuBJMjUb8uoQ1x3CYLHN24wV
     9c434W65R92ZLMkYUM+gBixh3DkiRXd89mnihcxqp15Ls7yhZJIW08e5DZKIKNbiH
    10HfM+PFkdq4DJV473hhASjSKgdVBngZuuOdzk6Vi53jOQFh7IE38YeT71xBJ0IRBh
    11qiCfcXsS/mzRrFe7PHMG9GPlWzMP/ede5ICOrauncjgA/3UBR6i1o9RfzX6b885o
    12M9c5dHdkhd3WjuwEBYrCj9gtbMRyqC7kZbLEYhWcfR/Psp/0SKyF4FAP8O8AItiC
    13rc4BQYJn/3GG7b7SUReu2PyyDFPwJW3r68x6WQEbSclHq+3iRfNKTiOBe1vc0zI+
    14r2FnahlKrw3/hqz4jDUJfgooeiKHrev2SJOKZJOhzGqyL4ujnTdKp+NRpoRRXy+t
    15hxQ3BPag
    16=NgtJ
    17-----END PGP SIGNATURE-----
    

    Timestamp of file with hash c29a816f655c66172f117b610389a5a791097d2c042b69406155146f2572f5c9 -

  11. MarcoFalke merged this on Jun 24, 2020
  12. MarcoFalke closed this on Jun 24, 2020

  13. Fabcien referenced this in commit e1f1d7ef99 on Feb 1, 2021
  14. kittywhiskers referenced this in commit fc3ac7c388 on Mar 8, 2021
  15. kittywhiskers referenced this in commit 4de4df63a7 on May 18, 2021
  16. kittywhiskers referenced this in commit d71f9f554d on May 19, 2021
  17. kittywhiskers referenced this in commit 41642ff199 on May 20, 2021
  18. kittywhiskers referenced this in commit 5c71fc727b on May 20, 2021
  19. kittywhiskers referenced this in commit 01272b159d on May 20, 2021
  20. PastaPastaPasta referenced this in commit b76e7fec1f on May 21, 2021
  21. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me