diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2020-11-29 19:33:22 +0100 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2020-12-01 18:36:39 +0100 |
commit | 1e62350ca20898189904a88dfef9ea11ddcd8626 (patch) | |
tree | 4c59267f85c5691faa84656cb0cecb0d386a247e /src | |
parent | c502a6dbfb854ca827a5a3925394f9e09d29b898 (diff) |
refactor: Improve use of explicit keyword
Diffstat (limited to 'src')
-rw-r--r-- | src/net_processing.cpp | 2 | ||||
-rw-r--r-- | src/node/interfaces.cpp | 2 | ||||
-rw-r--r-- | src/pubkey.h | 2 | ||||
-rw-r--r-- | src/qt/test/addressbooktests.h | 2 | ||||
-rw-r--r-- | src/qt/test/rpcnestedtests.h | 2 | ||||
-rw-r--r-- | src/qt/test/wallettests.h | 2 | ||||
-rw-r--r-- | src/rpc/request.h | 2 | ||||
-rw-r--r-- | src/script/descriptor.cpp | 2 | ||||
-rw-r--r-- | src/script/standard.h | 2 | ||||
-rw-r--r-- | src/test/fuzz/signature_checker.cpp | 2 | ||||
-rw-r--r-- | src/test/util/logging.h | 2 | ||||
-rw-r--r-- | src/test/util_tests.cpp | 2 | ||||
-rw-r--r-- | src/tinyformat.h | 4 | ||||
-rw-r--r-- | src/txmempool.h | 2 | ||||
-rw-r--r-- | src/txrequest.cpp | 4 | ||||
-rw-r--r-- | src/validation.cpp | 4 | ||||
-rw-r--r-- | src/wallet/bdb.h | 2 | ||||
-rw-r--r-- | src/wallet/scriptpubkeyman.h | 4 |
18 files changed, 22 insertions, 22 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp index e9915a3091..ec5400c3d8 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -451,7 +451,7 @@ struct Peer { /** Work queue of items requested by this peer **/ std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex); - Peer(NodeId id) : m_id(id) {} + explicit Peer(NodeId id) : m_id(id) {} }; using PeerRef = std::shared_ptr<Peer>; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 77a5957a56..a8c8be05fb 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -64,7 +64,7 @@ namespace { class NodeImpl : public Node { public: - NodeImpl(NodeContext* context) { setContext(context); } + explicit NodeImpl(NodeContext* context) { setContext(context); } void initLogging() override { InitLogging(*Assert(m_context->args)); } void initParameterInteraction() override { InitParameterInteraction(*Assert(m_context->args)); } bilingual_str getWarnings() override { return GetWarnings(true); } diff --git a/src/pubkey.h b/src/pubkey.h index 80d0c18540..d60520ac44 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -223,7 +223,7 @@ private: public: /** Construct an x-only pubkey from exactly 32 bytes. */ - XOnlyPubKey(Span<const unsigned char> bytes); + explicit XOnlyPubKey(Span<const unsigned char> bytes); /** Verify a Schnorr signature against this public key. * diff --git a/src/qt/test/addressbooktests.h b/src/qt/test/addressbooktests.h index 5de89c7592..e6d24f202f 100644 --- a/src/qt/test/addressbooktests.h +++ b/src/qt/test/addressbooktests.h @@ -15,7 +15,7 @@ class Node; class AddressBookTests : public QObject { public: - AddressBookTests(interfaces::Node& node) : m_node(node) {} + explicit AddressBookTests(interfaces::Node& node) : m_node(node) {} interfaces::Node& m_node; Q_OBJECT diff --git a/src/qt/test/rpcnestedtests.h b/src/qt/test/rpcnestedtests.h index 0a00d1113a..320275129d 100644 --- a/src/qt/test/rpcnestedtests.h +++ b/src/qt/test/rpcnestedtests.h @@ -15,7 +15,7 @@ class Node; class RPCNestedTests : public QObject { public: - RPCNestedTests(interfaces::Node& node) : m_node(node) {} + explicit RPCNestedTests(interfaces::Node& node) : m_node(node) {} interfaces::Node& m_node; Q_OBJECT diff --git a/src/qt/test/wallettests.h b/src/qt/test/wallettests.h index 8ee40bf07f..dfca3370f7 100644 --- a/src/qt/test/wallettests.h +++ b/src/qt/test/wallettests.h @@ -15,7 +15,7 @@ class Node; class WalletTests : public QObject { public: - WalletTests(interfaces::Node& node) : m_node(node) {} + explicit WalletTests(interfaces::Node& node) : m_node(node) {} interfaces::Node& m_node; Q_OBJECT diff --git a/src/rpc/request.h b/src/rpc/request.h index 4761e9e371..1241d999a8 100644 --- a/src/rpc/request.h +++ b/src/rpc/request.h @@ -40,7 +40,7 @@ public: std::string peerAddr; const util::Ref& context; - JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), fHelp(false), context(context) {} + explicit JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), fHelp(false), context(context) {} //! Initializes request information from another request object and the //! given context. The implementation should be updated if any members are diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 8d8fa185ba..e5ba9ba6d2 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -156,7 +156,7 @@ protected: uint32_t m_expr_index; public: - PubkeyProvider(uint32_t exp_index) : m_expr_index(exp_index) {} + explicit PubkeyProvider(uint32_t exp_index) : m_expr_index(exp_index) {} virtual ~PubkeyProvider() = default; diff --git a/src/script/standard.h b/src/script/standard.h index 721203385e..4d1ef61964 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -28,7 +28,7 @@ protected: public: BaseHash() : m_hash() {} - BaseHash(const HashType& in) : m_hash(in) {} + explicit BaseHash(const HashType& in) : m_hash(in) {} unsigned char* begin() { diff --git a/src/test/fuzz/signature_checker.cpp b/src/test/fuzz/signature_checker.cpp index e121c89665..970452dbcc 100644 --- a/src/test/fuzz/signature_checker.cpp +++ b/src/test/fuzz/signature_checker.cpp @@ -24,7 +24,7 @@ class FuzzedSignatureChecker : public BaseSignatureChecker FuzzedDataProvider& m_fuzzed_data_provider; public: - FuzzedSignatureChecker(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider(fuzzed_data_provider) + explicit FuzzedSignatureChecker(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider(fuzzed_data_provider) { } diff --git a/src/test/util/logging.h b/src/test/util/logging.h index 1fcf7ca305..a49f9a7292 100644 --- a/src/test/util/logging.h +++ b/src/test/util/logging.h @@ -32,7 +32,7 @@ class DebugLogHelper void check_found(); public: - DebugLogHelper(std::string message, MatchFn match = [](const std::string*){ return true; }); + explicit DebugLogHelper(std::string message, MatchFn match = [](const std::string*){ return true; }); ~DebugLogHelper() { check_found(); } }; diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 36fa1a0299..131508f5f8 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -231,7 +231,7 @@ public: Optional<std::vector<std::string>> list_value; const char* error = nullptr; - Expect(util::SettingsValue s) : setting(std::move(s)) {} + explicit Expect(util::SettingsValue s) : setting(std::move(s)) {} Expect& DefaultString() { default_string = true; return *this; } Expect& DefaultInt() { default_int = true; return *this; } Expect& DefaultBool() { default_bool = true; return *this; } diff --git a/src/tinyformat.h b/src/tinyformat.h index be63f2d5d8..bc893ccda5 100644 --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -514,7 +514,7 @@ class FormatArg { } template<typename T> - FormatArg(const T& value) + explicit FormatArg(const T& value) : m_value(static_cast<const void*>(&value)), m_formatImpl(&formatImpl<T>), m_toIntImpl(&toIntImpl<T>) @@ -970,7 +970,7 @@ class FormatListN : public FormatList public: #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES template<typename... Args> - FormatListN(const Args&... args) + explicit FormatListN(const Args&... args) : FormatList(&m_formatterStore[0], N), m_formatterStore { FormatArg(args)... } { static_assert(sizeof...(args) == N, "Number of args must be N"); } diff --git a/src/txmempool.h b/src/txmempool.h index 78ad62aae6..15797cbc00 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -855,7 +855,7 @@ public: class EpochGuard { const CTxMemPool& pool; public: - EpochGuard(const CTxMemPool& in); + explicit EpochGuard(const CTxMemPool& in); ~EpochGuard(); }; // N.B. GetFreshEpoch modifies mutable state via the EpochGuard construction diff --git a/src/txrequest.cpp b/src/txrequest.cpp index 09eb78e927..e54c073328 100644 --- a/src/txrequest.cpp +++ b/src/txrequest.cpp @@ -170,7 +170,7 @@ using ByTxHashView = std::tuple<const uint256&, State, Priority>; class ByTxHashViewExtractor { const PriorityComputer& m_computer; public: - ByTxHashViewExtractor(const PriorityComputer& computer) : m_computer(computer) {} + explicit ByTxHashViewExtractor(const PriorityComputer& computer) : m_computer(computer) {} using result_type = ByTxHashView; result_type operator()(const Announcement& ann) const { @@ -522,7 +522,7 @@ private: } public: - Impl(bool deterministic) : + explicit Impl(bool deterministic) : m_computer(deterministic), // Explicitly initialize m_index as we need to pass a reference to m_computer to ByTxHashViewExtractor. m_index(boost::make_tuple( diff --git a/src/validation.cpp b/src/validation.cpp index d8f7bfc913..a774e76fa9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -449,7 +449,7 @@ namespace { class MemPoolAccept { public: - MemPoolAccept(CTxMemPool& mempool) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&::ChainstateActive().CoinsTip(), m_pool), + explicit MemPoolAccept(CTxMemPool& mempool) : m_pool(mempool), m_view(&m_dummy), m_viewmempool(&::ChainstateActive().CoinsTip(), m_pool), m_limit_ancestors(gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT)), m_limit_ancestor_size(gArgs.GetArg("-limitancestorsize", DEFAULT_ANCESTOR_SIZE_LIMIT)*1000), m_limit_descendants(gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)), @@ -482,7 +482,7 @@ private: // All the intermediate state that gets passed between the various levels // of checking a given transaction. struct Workspace { - Workspace(const CTransactionRef& ptx) : m_ptx(ptx), m_hash(ptx->GetHash()) {} + explicit Workspace(const CTransactionRef& ptx) : m_ptx(ptx), m_hash(ptx->GetHash()) {} std::set<uint256> m_conflicts; CTxMemPool::setEntries m_all_conflicting; CTxMemPool::setEntries m_ancestors; diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index 9073c1b6b3..4f97665f08 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -56,7 +56,7 @@ public: std::unordered_map<std::string, WalletDatabaseFileId> m_fileids; std::condition_variable_any m_db_in_use; - BerkeleyEnvironment(const fs::path& env_directory); + explicit BerkeleyEnvironment(const fs::path& env_directory); BerkeleyEnvironment(); ~BerkeleyEnvironment(); void Reset(); diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 43791acfcf..cec46a0fbb 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -172,7 +172,7 @@ protected: WalletStorage& m_storage; public: - ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {} + explicit ScriptPubKeyMan(WalletStorage& storage) : m_storage(storage) {} virtual ~ScriptPubKeyMan() {}; virtual bool GetNewDestination(const OutputType type, CTxDestination& dest, std::string& error) { return false; } virtual isminetype IsMine(const CScript& script) const { return ISMINE_NO; } @@ -504,7 +504,7 @@ class LegacySigningProvider : public SigningProvider private: const LegacyScriptPubKeyMan& m_spk_man; public: - LegacySigningProvider(const LegacyScriptPubKeyMan& spk_man) : m_spk_man(spk_man) {} + explicit LegacySigningProvider(const LegacyScriptPubKeyMan& spk_man) : m_spk_man(spk_man) {} bool GetCScript(const CScriptID &scriptid, CScript& script) const override { return m_spk_man.GetCScript(scriptid, script); } bool HaveCScript(const CScriptID &scriptid) const override { return m_spk_man.HaveCScript(scriptid); } |