mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 06:04:42 +02:00
Merge bitcoin/bitcoin#35679: fuzz: Remove unused DeserializeFromFuzzingInput params overload
afab8d4225fuzz, refactor: Remove `Serialize` overload (Hennadii Stepanov)efa7f8c143fuzz: Remove unused `DeserializeFromFuzzingInput` params overload (Hennadii Stepanov) Pull request description: Clang recently enabled `-Wunused-template` under `-Wall` (see https://github.com/llvm/llvm-project/pull/206123, https://github.com/llvm/llvm-project/pull/207848, https://github.com/llvm/llvm-project/pull/208001). Our codebase [triggers](https://my.cdash.org/builds/3714664/build) some of these warnings. This PR handles the simplest case, where the unused template function can simply be removed. Other cases need different approaches, as their usage depends on the actual TU they are compiled in. Those are left for follow-ups. While cleaning up `src/test/fuzz/deserialize.cpp`, another [suggestion](https://github.com/bitcoin/bitcoin/pull/35679#issuecomment-4907171813) has been addressed. ACKs for top commit: maflcko: lgtm ACKafab8d4225brunoerg: reACKafab8d4225frankomosh: Review ACKafab8d4225Tree-SHA512: 60e98034aa642a8bc0e43dd6c02e60927b5b51be21bbef5812569c797f5d80a04011bced43a34e237e454008382c792a8f7adbde960268f6ae2c0fe3bb2749b7
This commit is contained in:
@@ -57,14 +57,6 @@ namespace {
|
||||
struct invalid_fuzzing_input_exception : public std::exception {
|
||||
};
|
||||
|
||||
template <typename T, typename P>
|
||||
DataStream Serialize(const T& obj, const P& params)
|
||||
{
|
||||
DataStream ds{};
|
||||
ds << params(obj);
|
||||
return ds;
|
||||
}
|
||||
|
||||
template <typename T, typename P>
|
||||
T Deserialize(DataStream&& ds, const P& params)
|
||||
{
|
||||
@@ -73,17 +65,6 @@ T Deserialize(DataStream&& ds, const P& params)
|
||||
return obj;
|
||||
}
|
||||
|
||||
template <typename T, typename P>
|
||||
void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params)
|
||||
{
|
||||
try {
|
||||
SpanReader{buffer} >> params(obj);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
throw invalid_fuzzing_input_exception();
|
||||
}
|
||||
assert(buffer.empty() || !Serialize(obj, params).empty());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DataStream Serialize(const T& obj)
|
||||
{
|
||||
@@ -127,7 +108,7 @@ T DeserializeConstructFromFuzzingInput(FuzzBufferType buffer)
|
||||
template <typename T, typename P>
|
||||
void AssertEqualAfterSerializeDeserialize(const T& obj, const P& params)
|
||||
{
|
||||
assert(Deserialize<T>(Serialize(obj, params), params) == obj);
|
||||
assert(Deserialize<T>(Serialize(params(obj)), params) == obj);
|
||||
}
|
||||
template <typename T>
|
||||
void AssertEqualAfterSerializeDeserialize(const T& obj)
|
||||
|
||||
Reference in New Issue
Block a user