Skip to content

Commit a7bc9b7

Browse files
committed
Merge bitcoin/bitcoin#30229: fuzz: Use std::span in FuzzBufferType
faa41e2 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 faa41e2 Tree-SHA512: 54bcaf51c83a1b48739cd7f1e8445c6eba0eb04231bce5c35591a47dddb3890ffcaf562cf932930443c80ab0e66950c4619560e6692240de0c52aeef3214facd
2 parents d0cb516 + faa41e2 commit a7bc9b7

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/test/fuzz/bitset.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
namespace {
1414

15-
/** Pop the first byte from a Span<const uint8_t>, and return it. */
16-
uint8_t ReadByte(Span<const uint8_t>& buffer)
15+
/** Pop the first byte from a byte-span, and return it. */
16+
uint8_t ReadByte(FuzzBufferType& buffer)
1717
{
1818
if (buffer.empty()) return 0;
1919
uint8_t ret = buffer.front();
@@ -23,7 +23,7 @@ uint8_t ReadByte(Span<const uint8_t>& buffer)
2323

2424
/** Perform a simulation fuzz test on BitSet type S. */
2525
template<typename S>
26-
void TestType(Span<const uint8_t> buffer)
26+
void TestType(FuzzBufferType buffer)
2727
{
2828
/** This fuzz test's design is based on the assumption that the actual bits stored in the
2929
* bitsets and their simulations do not matter for the purpose of detecting edge cases, thus

src/test/fuzz/fuzz.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
#ifndef BITCOIN_TEST_FUZZ_FUZZ_H
66
#define BITCOIN_TEST_FUZZ_FUZZ_H
77

8-
#include <span.h>
9-
108
#include <cstdint>
119
#include <functional>
10+
#include <span>
1211
#include <string_view>
1312

1413
/**
@@ -23,7 +22,7 @@
2322
#define LIMITED_WHILE(condition, limit) \
2423
for (unsigned _count{limit}; (condition) && _count; --_count)
2524

26-
using FuzzBufferType = Span<const uint8_t>;
25+
using FuzzBufferType = std::span<const uint8_t>;
2726

2827
using TypeTestOneInput = std::function<void(FuzzBufferType)>;
2928
struct FuzzTargetOptions {

0 commit comments

Comments
 (0)