From fab53ff1e5a995f40a110d6f9e1214f263908b46 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 31 Aug 2021 18:13:55 +0200 Subject: [PATCH 1/2] Remove unused SERIALIZE_METHODS for CBanEntry --- src/addrdb.h | 8 -------- src/test/fuzz/addrdb.cpp | 16 +--------------- src/test/fuzz/deserialize.cpp | 4 ---- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/addrdb.h b/src/addrdb.h index 1e0ccb1f60..567b9973b7 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -8,10 +8,8 @@ #include #include // For banmap_t -#include #include -#include #include class CAddress; @@ -44,12 +42,6 @@ public: */ explicit CBanEntry(const UniValue& json); - SERIALIZE_METHODS(CBanEntry, obj) - { - uint8_t ban_reason = 2; //! For backward compatibility - READWRITE(obj.nVersion, obj.nCreateTime, obj.nBanUntil, ban_reason); - } - void SetNull() { nVersion = CBanEntry::CURRENT_VERSION; diff --git a/src/test/fuzz/addrdb.cpp b/src/test/fuzz/addrdb.cpp index d15c785673..44df3576c4 100644 --- a/src/test/fuzz/addrdb.cpp +++ b/src/test/fuzz/addrdb.cpp @@ -18,20 +18,6 @@ FUZZ_TARGET(addrdb) FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); // The point of this code is to exercise all CBanEntry constructors. - const CBanEntry ban_entry = [&] { - switch (fuzzed_data_provider.ConsumeIntegralInRange(0, 2)) { - case 0: - return CBanEntry{fuzzed_data_provider.ConsumeIntegral()}; - break; - case 1: { - const std::optional ban_entry = ConsumeDeserializable(fuzzed_data_provider); - if (ban_entry) { - return *ban_entry; - } - break; - } - } - return CBanEntry{}; - }(); + const CBanEntry ban_entry{fuzzed_data_provider.ConsumeIntegral()}; (void)ban_entry; // currently unused } diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp index 49503e8dc6..cfbbe77311 100644 --- a/src/test/fuzz/deserialize.cpp +++ b/src/test/fuzz/deserialize.cpp @@ -195,10 +195,6 @@ FUZZ_TARGET_DESERIALIZE(blockheader_deserialize, { CBlockHeader bh; DeserializeFromFuzzingInput(buffer, bh); }) -FUZZ_TARGET_DESERIALIZE(banentry_deserialize, { - CBanEntry be; - DeserializeFromFuzzingInput(buffer, be); -}) FUZZ_TARGET_DESERIALIZE(txundo_deserialize, { CTxUndo tu; DeserializeFromFuzzingInput(buffer, tu); From fa3bd9de99ee2bdfce2010e9367391a146e41878 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 31 Aug 2021 18:31:03 +0200 Subject: [PATCH 2/2] Remove CBanEntry::SetNull --- src/addrdb.h | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/addrdb.h b/src/addrdb.h index 567b9973b7..26400ee0b6 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -19,21 +19,15 @@ class CDataStream; class CBanEntry { public: - static const int CURRENT_VERSION=1; - int nVersion; - int64_t nCreateTime; - int64_t nBanUntil; + static constexpr int CURRENT_VERSION{1}; + int nVersion{CBanEntry::CURRENT_VERSION}; + int64_t nCreateTime{0}; + int64_t nBanUntil{0}; - CBanEntry() - { - SetNull(); - } + CBanEntry() {} explicit CBanEntry(int64_t nCreateTimeIn) - { - SetNull(); - nCreateTime = nCreateTimeIn; - } + : nCreateTime{nCreateTimeIn} {} /** * Create a ban entry from JSON. @@ -42,13 +36,6 @@ public: */ explicit CBanEntry(const UniValue& json); - void SetNull() - { - nVersion = CBanEntry::CURRENT_VERSION; - nCreateTime = 0; - nBanUntil = 0; - } - /** * Generate a JSON representation of this ban entry. * @return JSON suitable for passing to the `CBanEntry(const UniValue&)` constructor.