aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2024-06-12 12:51:46 +0200
committerVasil Dimov <vd@FreeBSD.org>2024-06-14 14:44:26 +0200
commitb51d75ea97ee0d01ee586e40a30cb68c0bf7ffd3 (patch)
tree20d99de8c58bced60622a7513f109b513fcdd523
parent0b94fb87206616e475566c3667cbaad0e9faa5b0 (diff)
downloadbitcoin-b51d75ea97ee0d01ee586e40a30cb68c0bf7ffd3.tar.xz
fuzz: simplify FuzzedSock::m_peek_data
`FuzzedSock::m_peek_data` need not be an optional of a vector. It can be just a vector whereas an empty vector denotes "no peek data".
-rw-r--r--src/test/fuzz/util/net.cpp6
-rw-r--r--src/test/fuzz/util/net.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/test/fuzz/util/net.cpp b/src/test/fuzz/util/net.cpp
index 5e7aae670e..562fa4ce68 100644
--- a/src/test/fuzz/util/net.cpp
+++ b/src/test/fuzz/util/net.cpp
@@ -191,11 +191,11 @@ ssize_t FuzzedSock::Recv(void* buf, size_t len, int flags) const
}
std::vector<uint8_t> random_bytes;
bool pad_to_len_bytes{m_fuzzed_data_provider.ConsumeBool()};
- if (m_peek_data.has_value()) {
+ if (!m_peek_data.empty()) {
// `MSG_PEEK` was used in the preceding `Recv()` call, return `m_peek_data`.
- random_bytes = m_peek_data.value();
+ random_bytes = m_peek_data;
if ((flags & MSG_PEEK) == 0) {
- m_peek_data.reset();
+ m_peek_data.clear();
}
pad_to_len_bytes = false;
} else if ((flags & MSG_PEEK) != 0) {
diff --git a/src/test/fuzz/util/net.h b/src/test/fuzz/util/net.h
index ed02680676..1a5902329e 100644
--- a/src/test/fuzz/util/net.h
+++ b/src/test/fuzz/util/net.h
@@ -43,7 +43,7 @@ class FuzzedSock : public Sock
* If `MSG_PEEK` is used, then our `Recv()` returns some random data as usual, but on the next
* `Recv()` call we must return the same data, thus we remember it here.
*/
- mutable std::optional<std::vector<uint8_t>> m_peek_data;
+ mutable std::vector<uint8_t> m_peek_data;
/**
* Whether to pretend that the socket is select(2)-able. This is randomly set in the