0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

Merge bitcoin/bitcoin#30229: fuzz: Use std::span in FuzzBufferType

faa41e29d5 fuzz: Use std::span in FuzzBufferType (MarcoFalke)

Pull request description:

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

  ```
  error: 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.

ACKs for top commit:
  dergoegge:
    utACK faa41e29d5

Tree-SHA512: 54bcaf51c83a1b48739cd7f1e8445c6eba0eb04231bce5c35591a47dddb3890ffcaf562cf932930443c80ab0e66950c4619560e6692240de0c52aeef3214facd
This commit is contained in:
merge-script 2024-06-12 18:16:07 +01:00
commit a7bc9b76e7
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
2 changed files with 5 additions and 6 deletions

View file

@ -12,8 +12,8 @@
namespace {
/** Pop the first byte from a Span<const uint8_t>, and return it. */
uint8_t ReadByte(Span<const uint8_t>& buffer)
/** Pop the first byte from a byte-span, and return it. */
uint8_t ReadByte(FuzzBufferType& buffer)
{
if (buffer.empty()) return 0;
uint8_t ret = buffer.front();
@ -23,7 +23,7 @@ uint8_t ReadByte(Span<const uint8_t>& buffer)
/** Perform a simulation fuzz test on BitSet type S. */
template<typename S>
void TestType(Span<const uint8_t> buffer)
void TestType(FuzzBufferType buffer)
{
/** This fuzz test's design is based on the assumption that the actual bits stored in the
* bitsets and their simulations do not matter for the purpose of detecting edge cases, thus

View file

@ -5,10 +5,9 @@
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
#define BITCOIN_TEST_FUZZ_FUZZ_H
#include <span.h>
#include <cstdint>
#include <functional>
#include <span>
#include <string_view>
/**
@ -23,7 +22,7 @@
#define LIMITED_WHILE(condition, limit) \
for (unsigned _count{limit}; (condition) && _count; --_count)
using FuzzBufferType = Span<const uint8_t>;
using FuzzBufferType = std::span<const uint8_t>;
using TypeTestOneInput = std::function<void(FuzzBufferType)>;
struct FuzzTargetOptions {