From 365539c84691d470b44d35df374d8c049f8c1192 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Sun, 31 Jan 2021 17:28:23 +0100 Subject: [PATCH] refactor: init vectors via std::{begin,end} to avoid pointer arithmetic --- src/bench/data.cpp | 2 +- src/chainparams.cpp | 5 ++--- src/protocol.cpp | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/bench/data.cpp b/src/bench/data.cpp index 0ae4c7cad4d..481e3721057 100644 --- a/src/bench/data.cpp +++ b/src/bench/data.cpp @@ -8,7 +8,7 @@ namespace benchmark { namespace data { #include -const std::vector block413567{block413567_raw, block413567_raw + sizeof(block413567_raw) / sizeof(block413567_raw[0])}; +const std::vector block413567{std::begin(block413567_raw), std::end(block413567_raw)}; } // namespace data } // namespace benchmark diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 88cf5ef0a88..a991922d58d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -10,7 +10,6 @@ #include // for signet block challenge hash #include #include -#include #include #include @@ -136,7 +135,7 @@ public: bech32_hrp = "bc"; - vFixedSeeds = std::vector(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main)); + vFixedSeeds = std::vector(std::begin(pnSeed6_main), std::end(pnSeed6_main)); fDefaultConsistencyChecks = false; fRequireStandard = true; @@ -237,7 +236,7 @@ public: bech32_hrp = "tb"; - vFixedSeeds = std::vector(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); + vFixedSeeds = std::vector(std::begin(pnSeed6_test), std::end(pnSeed6_test)); fDefaultConsistencyChecks = false; fRequireStandard = false; diff --git a/src/protocol.cpp b/src/protocol.cpp index 56e738eaa87..0b893b9272a 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -5,7 +5,6 @@ #include -#include #include static std::atomic g_initial_block_download_completed(false); @@ -86,7 +85,7 @@ const static std::string allNetMessageTypes[] = { NetMsgType::CFCHECKPT, NetMsgType::WTXIDRELAY, }; -const static std::vector allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes)); +const static std::vector allNetMessageTypesVec(std::begin(allNetMessageTypes), std::end(allNetMessageTypes)); CMessageHeader::CMessageHeader() {