fuzz: Use std::span in FuzzBufferType #30229

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2406-fuzz-span changing 2 files +5 −6
  1. maflcko commented at 12:44 pm on June 5, 2024: member

    The use of Span is problematic, because it lacks methods such as rbegin, leading to compile failures when used:

    0error: no member named 'rbegin' in 'Span<const unsigned char>'
    

    One could fix Span, but it seems better to use std::span, given that Span will be removed anyway in the long term.

  2. DrahtBot commented at 12:45 pm on June 5, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK dergoegge

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. DrahtBot added the label Tests on Jun 5, 2024
  4. dergoegge commented at 9:40 am on June 10, 2024: member
    I’m out of the loop on converting Span to std::span, why is ok to do this here but not everywhere?
  5. maflcko commented at 9:52 am on June 10, 2024: member

    I’m out of the loop on converting Span to std::span, why is ok to do this here but not everywhere?

    Good question!

    It is quite some work to do it everywhere (I am working on it), because Span and std::span differ in their interface. (One is lacking methods of the other, and vice-versa).

    However, as long as the replacement compiles, it should be safe.

    Moreover, FuzzBufferType is a distinct type, mainly used to denote the type of a byte-view, which will be passed to FuzzedDataProvider, so the switch can be done independently here, without affecting non-fuzz code.

  6. dergoegge approved
  7. dergoegge commented at 9:54 am on June 10, 2024: member
    utACK fabc9b02331ad6d5cbae3d351721e7e5d9585df0
  8. maflcko requested review from fanquake on Jun 12, 2024
  9. fanquake commented at 12:32 pm on June 12, 2024: member

    I think this is ok to do, but you’ll need adjust the bitset code instroduced in #30160:

    0test/fuzz/bitset.cpp:284:23: error: no matching function for call to 'ReadByte'
    1    unsigned typdat = ReadByte(buffer) % 8;
    2                      ^~~~~~~~
    3test/fuzz/bitset.cpp:16:9: note: candidate function not viable: no known conversion from 'FuzzBufferType' (aka 'span<const unsigned char>') to 'Span<const uint8_t> &' (aka 'Span<const unsigned char> &') for 1st argument
    4uint8_t ReadByte(Span<const uint8_t>& buffer)
    5        ^
    61 error generated.
    
  10. fuzz: Use std::span in FuzzBufferType faa41e29d5
  11. maflcko force-pushed on Jun 12, 2024
  12. maflcko commented at 1:28 pm on June 12, 2024: member
    Thanks for spotting the silent merge conflict. Rebased.
  13. dergoegge approved
  14. dergoegge commented at 5:05 pm on June 12, 2024: member
    utACK faa41e29d5b90e62179d651f4010272dae685621
  15. fanquake merged this on Jun 12, 2024
  16. fanquake closed this on Jun 12, 2024

  17. maflcko deleted the branch on Jun 12, 2024

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-11-21 15:12 UTC

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