diff --git a/src/addrdb.h b/src/addrdb.h --- a/src/addrdb.h +++ b/src/addrdb.h @@ -33,7 +33,7 @@ CBanEntry() { SetNull(); } - CBanEntry(int64_t nCreateTimeIn) { + explicit CBanEntry(int64_t nCreateTimeIn) { SetNull(); nCreateTime = nCreateTimeIn; } diff --git a/src/base58.cpp b/src/base58.cpp --- a/src/base58.cpp +++ b/src/base58.cpp @@ -214,7 +214,8 @@ const CChainParams &m_params; public: - DestinationEncoder(const CChainParams ¶ms) : m_params(params) {} + explicit DestinationEncoder(const CChainParams ¶ms) + : m_params(params) {} std::string operator()(const CKeyID &id) const { std::vector data = diff --git a/src/bench/checkqueue.cpp b/src/bench/checkqueue.cpp --- a/src/bench/checkqueue.cpp +++ b/src/bench/checkqueue.cpp @@ -26,7 +26,7 @@ struct PrevectorJob { prevector p; PrevectorJob() {} - PrevectorJob(FastRandomContext &insecure_rand) { + explicit PrevectorJob(FastRandomContext &insecure_rand) { p.resize(insecure_rand.randrange(PREVECTOR_SIZE * 2)); } bool operator()() { return true; } diff --git a/src/blockencodings.h b/src/blockencodings.h --- a/src/blockencodings.h +++ b/src/blockencodings.h @@ -18,7 +18,7 @@ CTransactionRef &tx; public: - TransactionCompressor(CTransactionRef &txIn) : tx(txIn) {} + explicit TransactionCompressor(CTransactionRef &txIn) : tx(txIn) {} ADD_SERIALIZE_METHODS; @@ -84,7 +84,7 @@ std::vector txn; BlockTransactions() {} - BlockTransactions(const BlockTransactionsRequest &req) + explicit BlockTransactions(const BlockTransactionsRequest &req) : blockhash(req.blockhash), txn(req.indices.size()) {} ADD_SERIALIZE_METHODS; diff --git a/src/chain.h b/src/chain.h --- a/src/chain.h +++ b/src/chain.h @@ -124,7 +124,7 @@ CBlockIndex() { SetNull(); } - CBlockIndex(const CBlockHeader &block) { + explicit CBlockIndex(const CBlockHeader &block) { SetNull(); nVersion = block.nVersion; diff --git a/src/compressor.h b/src/compressor.h --- a/src/compressor.h +++ b/src/compressor.h @@ -55,7 +55,7 @@ bool Decompress(unsigned int nSize, const std::vector &out); public: - CScriptCompressor(CScript &scriptIn) : script(scriptIn) {} + explicit CScriptCompressor(CScript &scriptIn) : script(scriptIn) {} template void Serialize(Stream &s) const { std::vector compr; @@ -98,7 +98,7 @@ static uint64_t CompressAmount(Amount nAmount); static Amount DecompressAmount(uint64_t nAmount); - CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) {} + explicit CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) {} ADD_SERIALIZE_METHODS; diff --git a/src/cuckoocache.h b/src/cuckoocache.h --- a/src/cuckoocache.h +++ b/src/cuckoocache.h @@ -55,7 +55,7 @@ * @post All calls to bit_is_set (without subsequent bit_unset) will return * true. */ - bit_packed_atomic_flags(uint32_t size) { + explicit bit_packed_atomic_flags(uint32_t size) { // pad out the size if needed size = (size + 7) / 8; mem.reset(new std::atomic[size]); diff --git a/src/dbwrapper.h b/src/dbwrapper.h --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -21,7 +21,8 @@ class dbwrapper_error : public std::runtime_error { public: - dbwrapper_error(const std::string &msg) : std::runtime_error(msg) {} + explicit dbwrapper_error(const std::string &msg) + : std::runtime_error(msg) {} }; class CDBWrapper; @@ -61,7 +62,7 @@ /** * @param[in] _parent CDBWrapper that this batch is to be submitted to */ - CDBBatch(const CDBWrapper &_parent) + explicit CDBBatch(const CDBWrapper &_parent) : parent(_parent), ssKey(SER_DISK, CLIENT_VERSION), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0){}; diff --git a/src/hash.h b/src/hash.h --- a/src/hash.h +++ b/src/hash.h @@ -173,7 +173,7 @@ Source *source; public: - CHashVerifier(Source *source_) + explicit CHashVerifier(Source *source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {} diff --git a/src/httprpc.cpp b/src/httprpc.cpp --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -48,7 +48,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface { public: - HTTPRPCTimerInterface(struct event_base *_base) : base(_base) {} + explicit HTTPRPCTimerInterface(struct event_base *_base) : base(_base) {} const char *Name() override { return "HTTP"; } diff --git a/src/httpserver.h b/src/httpserver.h --- a/src/httpserver.h +++ b/src/httpserver.h @@ -72,7 +72,7 @@ bool replySent; public: - HTTPRequest(struct evhttp_request *req); + explicit HTTPRequest(struct evhttp_request *req); ~HTTPRequest(); enum RequestMethod { UNKNOWN, GET, POST, HEAD, PUT, OPTIONS }; diff --git a/src/httpserver.cpp b/src/httpserver.cpp --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -82,7 +82,7 @@ class ThreadCounter { public: WorkQueue &wq; - ThreadCounter(WorkQueue &w) : wq(w) { + explicit ThreadCounter(WorkQueue &w) : wq(w) { std::lock_guard lock(wq.cs); wq.numThreads += 1; } @@ -94,7 +94,7 @@ }; public: - WorkQueue(size_t _maxDepth) + explicit WorkQueue(size_t _maxDepth) : running(true), maxDepth(_maxDepth), numThreads(0) {} /** Precondition: worker threads have all stopped (call WaitExit) */ ~WorkQueue() {} diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -134,7 +134,8 @@ */ class CCoinsViewErrorCatcher final : public CCoinsViewBacked { public: - CCoinsViewErrorCatcher(CCoinsView *view) : CCoinsViewBacked(view) {} + explicit CCoinsViewErrorCatcher(CCoinsView *view) + : CCoinsViewBacked(view) {} bool GetCoin(const COutPoint &outpoint, Coin &coin) const override { try { return CCoinsViewBacked::GetCoin(outpoint, coin); diff --git a/src/limitedmap.h b/src/limitedmap.h --- a/src/limitedmap.h +++ b/src/limitedmap.h @@ -27,7 +27,7 @@ size_type nMaxSize; public: - limitedmap(size_type nMaxSizeIn) { + explicit limitedmap(size_type nMaxSizeIn) { assert(nMaxSizeIn > 0); nMaxSize = nMaxSizeIn; } diff --git a/src/miner.h b/src/miner.h --- a/src/miner.h +++ b/src/miner.h @@ -42,7 +42,7 @@ // Container for tracking updates to ancestor feerate as we include (parent) // transactions in a block struct CTxMemPoolModifiedEntry { - CTxMemPoolModifiedEntry(CTxMemPool::txiter entry) { + explicit CTxMemPoolModifiedEntry(CTxMemPool::txiter entry) { iter = entry; nSizeWithAncestors = entry->GetSizeWithAncestors(); nBillableSizeWithAncestors = entry->GetBillableSizeWithAncestors(); @@ -124,7 +124,7 @@ modtxscoreiter; struct update_for_parent_inclusion { - update_for_parent_inclusion(CTxMemPool::txiter it) : iter(it) {} + explicit update_for_parent_inclusion(CTxMemPool::txiter it) : iter(it) {} void operator()(CTxMemPoolModifiedEntry &e) { e.nModFeesWithAncestors -= iter->GetFee(); diff --git a/src/netaddress.h b/src/netaddress.h --- a/src/netaddress.h +++ b/src/netaddress.h @@ -36,7 +36,7 @@ public: CNetAddr(); - CNetAddr(const struct in_addr &ipv4Addr); + explicit CNetAddr(const struct in_addr &ipv4Addr); void SetIP(const CNetAddr &ip); private: @@ -100,7 +100,8 @@ std::vector GetGroup() const; int GetReachabilityFrom(const CNetAddr *paddrPartner = nullptr) const; - CNetAddr(const struct in6_addr &pipv6Addr, const uint32_t scope = 0); + explicit CNetAddr(const struct in6_addr &pipv6Addr, + const uint32_t scope = 0); bool GetIn6Addr(struct in6_addr *pipv6Addr) const; friend bool operator==(const CNetAddr &a, const CNetAddr &b); @@ -167,7 +168,7 @@ CService(); CService(const CNetAddr &ip, unsigned short port); CService(const struct in_addr &ipv4Addr, unsigned short port); - CService(const struct sockaddr_in &addr); + explicit CService(const struct sockaddr_in &addr); unsigned short GetPort() const; bool GetSockAddr(struct sockaddr *paddr, socklen_t *addrlen) const; bool SetSockAddr(const struct sockaddr *paddr); @@ -182,7 +183,7 @@ std::string ToStringIPPort() const; CService(const struct in6_addr &ipv6Addr, unsigned short port); - CService(const struct sockaddr_in6 &addr); + explicit CService(const struct sockaddr_in6 &addr); ADD_SERIALIZE_METHODS; diff --git a/src/netmessagemaker.h b/src/netmessagemaker.h --- a/src/netmessagemaker.h +++ b/src/netmessagemaker.h @@ -11,7 +11,7 @@ class CNetMsgMaker { public: - CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn) {} + explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn) {} template CSerializedNetMsg Make(int nFlags, std::string sCommand, diff --git a/src/policy/fees.h b/src/policy/fees.h --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -275,7 +275,7 @@ class FeeFilterRounder { public: /** Create new FeeFilterRounder */ - FeeFilterRounder(const CFeeRate &minIncrementalFee); + explicit FeeFilterRounder(const CFeeRate &minIncrementalFee); /** Quantize a minimum fee for privacy purpose before broadcast **/ Amount round(const Amount currentMinFee); diff --git a/src/primitives/block.h b/src/primitives/block.h --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -111,7 +111,8 @@ CBlockLocator() {} - CBlockLocator(const std::vector &vHaveIn) : vHave(vHaveIn) {} + explicit CBlockLocator(const std::vector &vHaveIn) + : vHave(vHaveIn) {} ADD_SERIALIZE_METHODS; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -385,7 +385,7 @@ : hashPrevouts(txdata.hashPrevouts), hashSequence(txdata.hashSequence), hashOutputs(txdata.hashOutputs) {} - PrecomputedTransactionData(const CTransaction &tx); + explicit PrecomputedTransactionData(const CTransaction &tx); }; #endif // BITCOIN_PRIMITIVES_TRANSACTION_H diff --git a/src/protocol.h b/src/protocol.h --- a/src/protocol.h +++ b/src/protocol.h @@ -49,7 +49,7 @@ }; typedef std::array MessageMagic; - CMessageHeader(const MessageMagic &pchMessageStartIn); + explicit CMessageHeader(const MessageMagic &pchMessageStartIn); CMessageHeader(const MessageMagic &pchMessageStartIn, const char *pszCommand, unsigned int nMessageSizeIn); diff --git a/src/pubkey.h b/src/pubkey.h --- a/src/pubkey.h +++ b/src/pubkey.h @@ -31,7 +31,7 @@ class CKeyID : public uint160 { public: CKeyID() : uint160() {} - CKeyID(const uint160 &in) : uint160(in) {} + explicit CKeyID(const uint160 &in) : uint160(in) {} }; typedef uint256 ChainCode; @@ -74,7 +74,9 @@ } //! Construct a public key from a byte vector. - CPubKey(const std::vector &_vch) { Set(_vch.begin(), _vch.end()); } + explicit CPubKey(const std::vector &_vch) { + Set(_vch.begin(), _vch.end()); + } //! Simple read-only vector-like interface to the pubkey data. unsigned int size() const { return GetLen(vch[0]); } diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -30,10 +30,10 @@ class CCoinControlWidgetItem : public QTreeWidgetItem { public: - CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) + explicit CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {} - CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {} - CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) + explicit CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {} + explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {} bool operator<(const QTreeWidgetItem &other) const override; diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -50,7 +50,7 @@ Q_OBJECT public: - FreespaceChecker(Intro *intro); + explicit FreespaceChecker(Intro *intro); enum Status { ST_OK, ST_ERROR }; diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp --- a/src/qt/notificator.cpp +++ b/src/qt/notificator.cpp @@ -74,7 +74,7 @@ class FreedesktopImage { public: FreedesktopImage() {} - FreedesktopImage(const QImage &img); + explicit FreedesktopImage(const QImage &img); static int metaType(); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -24,8 +24,8 @@ class TxViewDelegate : public QAbstractItemDelegate { Q_OBJECT public: - TxViewDelegate(const PlatformStyle *_platformStyle, - QObject *parent = nullptr) + explicit TxViewDelegate(const PlatformStyle *_platformStyle, + QObject *parent = nullptr) : QAbstractItemDelegate(parent), unit(BitcoinUnits::BCH), platformStyle(_platformStyle) {} diff --git a/src/qt/paymentrequestplus.cpp b/src/qt/paymentrequestplus.cpp --- a/src/qt/paymentrequestplus.cpp +++ b/src/qt/paymentrequestplus.cpp @@ -20,7 +20,7 @@ class SSLVerifyError : public std::runtime_error { public: - SSLVerifyError(std::string err) : std::runtime_error(err) {} + explicit SSLVerifyError(std::string err) : std::runtime_error(err) {} }; bool PaymentRequestPlus::parse(const QByteArray &data) { diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -66,7 +66,7 @@ static bool ipcSendCommandLine(); // parent should be QApplication object - PaymentServer(QObject *parent, bool startLocalServer = true); + explicit PaymentServer(QObject *parent, bool startLocalServer = true); ~PaymentServer(); // Load root certificate authorities. Pass nullptr (default) to read from diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -39,7 +39,7 @@ Q_OBJECT public: - ShutdownWindow(QWidget *parent = 0, Qt::WindowFlags f = 0); + explicit ShutdownWindow(QWidget *parent = nullptr, Qt::WindowFlags f = 0); static QWidget *showShutdownWindow(BitcoinGUI *window); protected: diff --git a/src/rest.cpp b/src/rest.cpp --- a/src/rest.cpp +++ b/src/rest.cpp @@ -45,7 +45,8 @@ CTxOut out; CCoin() : nHeight(0) {} - CCoin(Coin in) : nHeight(in.GetHeight()), out(std::move(in.GetTxOut())) {} + explicit CCoin(Coin in) + : nHeight(in.GetHeight()), out(std::move(in.GetTxOut())) {} ADD_SERIALIZE_METHODS; diff --git a/src/reverse_iterator.h b/src/reverse_iterator.h --- a/src/reverse_iterator.h +++ b/src/reverse_iterator.h @@ -15,7 +15,7 @@ T &x; public: - reverse_range(T &xin) : x(xin) {} + explicit reverse_range(T &xin) : x(xin) {} auto begin() const -> decltype(this->x.rbegin()) { return x.rbegin(); } diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -685,7 +685,7 @@ bool found; CValidationState state; - submitblock_StateCatcher(const uint256 &hashIn) + explicit submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {} protected: diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -140,7 +140,7 @@ public: CWallet *const pwallet; - DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} + explicit DescribeAddressVisitor(CWallet *_pwallet) : pwallet(_pwallet) {} UniValue operator()(const CNoDestination &dest) const { return UniValue(UniValue::VOBJ); diff --git a/src/rpc/server.h b/src/rpc/server.h --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -40,7 +40,8 @@ * care type. Only used by RPCTypeCheckObj. */ struct UniValueType { - UniValueType(UniValue::VType _type) : typeAny(false), type(_type) {} + explicit UniValueType(UniValue::VType _type) + : typeAny(false), type(_type) {} UniValueType() : typeAny(true) {} bool typeAny; UniValue::VType type; diff --git a/src/scheduler.h b/src/scheduler.h --- a/src/scheduler.h +++ b/src/scheduler.h @@ -107,7 +107,7 @@ void ProcessQueue(); public: - SingleThreadedSchedulerClient(CScheduler *pschedulerIn) + explicit SingleThreadedSchedulerClient(CScheduler *pschedulerIn) : m_pscheduler(pschedulerIn) {} void AddToProcessQueue(std::function func); diff --git a/src/scheduler.cpp b/src/scheduler.cpp --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -181,7 +181,7 @@ // to ensure both happen safely even if callback() throws. struct RAIICallbacksRunning { SingleThreadedSchedulerClient *instance; - RAIICallbacksRunning(SingleThreadedSchedulerClient *_instance) + explicit RAIICallbacksRunning(SingleThreadedSchedulerClient *_instance) : instance(_instance) {} ~RAIICallbacksRunning() { { diff --git a/src/script/sign.h b/src/script/sign.h --- a/src/script/sign.h +++ b/src/script/sign.h @@ -21,7 +21,8 @@ const CKeyStore *keystore; public: - BaseSignatureCreator(const CKeyStore *keystoreIn) : keystore(keystoreIn) {} + explicit BaseSignatureCreator(const CKeyStore *keystoreIn) + : keystore(keystoreIn) {} const CKeyStore &KeyStore() const { return *keystore; }; virtual ~BaseSignatureCreator() {} virtual const BaseSignatureChecker &Checker() const = 0; @@ -66,7 +67,7 @@ /** A signature creator that just produces 72-byte empty signatures. */ class DummySignatureCreator : public BaseSignatureCreator { public: - DummySignatureCreator(const CKeyStore *keystoreIn) + explicit DummySignatureCreator(const CKeyStore *keystoreIn) : BaseSignatureCreator(keystoreIn) {} const BaseSignatureChecker &Checker() const override; bool CreateSig(std::vector &vchSig, const CKeyID &keyid, diff --git a/src/script/standard.cpp b/src/script/standard.cpp --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -241,7 +241,7 @@ CScript *script; public: - CScriptVisitor(CScript *scriptin) { script = scriptin; } + explicit CScriptVisitor(CScript *scriptin) { script = scriptin; } bool operator()(const CNoDestination &dest) const { script->clear(); diff --git a/src/serialize.h b/src/serialize.h --- a/src/serialize.h +++ b/src/serialize.h @@ -412,7 +412,7 @@ I &n; public: - CVarInt(I &nIn) : n(nIn) {} + explicit CVarInt(I &nIn) : n(nIn) {} template void Serialize(Stream &s) const { WriteVarInt(s, n); @@ -428,7 +428,7 @@ uint64_t &n; public: - CCompactSize(uint64_t &nIn) : n(nIn) {} + explicit CCompactSize(uint64_t &nIn) : n(nIn) {} template void Serialize(Stream &s) const { WriteCompactSize(s, n); @@ -444,7 +444,7 @@ std::string &string; public: - LimitedString(std::string &_string) : string(_string) {} + explicit LimitedString(std::string &_string) : string(_string) {} template void Unserialize(Stream &s) { size_t size = ReadCompactSize(s); diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -161,8 +161,8 @@ * the allocation fails (hard fail), if it returns true the allocation * proceeds, but it could warn. */ - LockedPool(std::unique_ptr allocator, - LockingFailed_Callback lf_cb_in = nullptr); + explicit LockedPool(std::unique_ptr allocator, + LockingFailed_Callback lf_cb_in = nullptr); ~LockedPool(); /** @@ -235,7 +235,7 @@ } private: - LockedPoolManager(std::unique_ptr allocator); + explicit LockedPoolManager(std::unique_ptr allocator); /** Create a new LockedPoolManager specialized to the OS */ static void CreateInstance(); diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -87,7 +87,7 @@ std::string exp_addrType; public: - TestAddrTypeVisitor(const std::string &_exp_addrType) + explicit TestAddrTypeVisitor(const std::string &_exp_addrType) : exp_addrType(_exp_addrType) {} bool operator()(const CKeyID &id) const { return (exp_addrType == "pubkey"); @@ -106,7 +106,7 @@ std::vector exp_payload; public: - TestPayloadVisitor(std::vector &_exp_payload) + explicit TestPayloadVisitor(std::vector &_exp_payload) : exp_payload(_exp_payload) {} bool operator()(const CKeyID &id) const { uint160 exp_key(exp_payload); diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -24,7 +24,8 @@ std::string strHexMaster; std::vector vDerive; - TestVector(std::string strHexMasterIn) : strHexMaster(strHexMasterIn) {} + explicit TestVector(std::string strHexMasterIn) + : strHexMaster(strHexMasterIn) {} TestVector &operator()(std::string pub, std::string prv, unsigned int nChild) { diff --git a/src/test/blockencodings_tests.cpp b/src/test/blockencodings_tests.cpp --- a/src/test/blockencodings_tests.cpp +++ b/src/test/blockencodings_tests.cpp @@ -133,12 +133,12 @@ std::vector shorttxids; std::vector prefilledtxn; - TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig) { + explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs &orig) { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << orig; stream >> *this; } - TestHeaderAndShortIDs(const CBlock &block) + explicit TestHeaderAndShortIDs(const CBlock &block) : TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block)) {} uint64_t GetShortID(const uint256 &txhash) const { diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -76,7 +76,7 @@ class CCoinsViewCacheTest : public CCoinsViewCache { public: - CCoinsViewCacheTest(CCoinsView *_base) : CCoinsViewCache(_base) {} + explicit CCoinsViewCacheTest(CCoinsView *_base) : CCoinsViewCache(_base) {} void SelfTest() const { // Manually recompute the dynamic usage of the whole data, and compare diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -229,7 +229,7 @@ // different lengths. This is a terrible idea. std::string str; StringContentsSerializer() {} - StringContentsSerializer(const std::string &inp) : str(inp) {} + explicit StringContentsSerializer(const std::string &inp) : str(inp) {} StringContentsSerializer &operator+=(const std::string &s) { str += s; diff --git a/src/test/test_bitcoin.h b/src/test/test_bitcoin.h --- a/src/test/test_bitcoin.h +++ b/src/test/test_bitcoin.h @@ -54,7 +54,8 @@ struct BasicTestingSetup { ECCVerifyHandle globalVerifyHandle; - BasicTestingSetup(const std::string &chainName = CBaseChainParams::MAIN); + explicit BasicTestingSetup( + const std::string &chainName = CBaseChainParams::MAIN); ~BasicTestingSetup(); }; @@ -76,7 +77,8 @@ CScheduler scheduler; std::unique_ptr peerLogic; - TestingSetup(const std::string &chainName = CBaseChainParams::MAIN); + explicit TestingSetup( + const std::string &chainName = CBaseChainParams::MAIN); ~TestingSetup(); }; diff --git a/src/tinyformat.h b/src/tinyformat.h --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -554,7 +554,7 @@ FormatArg() {} template - FormatArg(const T &value) + explicit FormatArg(const T &value) : m_value(static_cast(&value)), m_formatImpl(&formatImpl), m_toIntImpl(&toIntImpl) {} @@ -905,7 +905,7 @@ public: #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES template - 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"); @@ -915,7 +915,8 @@ #define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \ \ template \ - FormatListN(TINYFORMAT_VARARGS(n)) : FormatList(&m_formatterStore[0], n) { \ + explicit FormatListN(TINYFORMAT_VARARGS(n)) \ + : FormatList(&m_formatterStore[0], n) { \ assert(n == N); \ init(0, TINYFORMAT_PASSARGS(n)); \ } \ diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -79,7 +79,7 @@ /** Create a new TorControlConnection. */ - TorControlConnection(struct event_base *base); + explicit TorControlConnection(struct event_base *base); ~TorControlConnection(); /** diff --git a/src/txdb.h b/src/txdb.h --- a/src/txdb.h +++ b/src/txdb.h @@ -70,7 +70,8 @@ CDBWrapper db; public: - CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); + explicit CCoinsViewDB(size_t nCacheSize, bool fMemory = false, + bool fWipe = false); bool GetCoin(const COutPoint &outpoint, Coin &coin) const override; bool HaveCoin(const COutPoint &outpoint) const override; @@ -109,7 +110,8 @@ /** Access to the block database (blocks/index/) */ class CBlockTreeDB : public CDBWrapper { public: - CBlockTreeDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); + explicit CBlockTreeDB(size_t nCacheSize, bool fMemory = false, + bool fWipe = false); private: CBlockTreeDB(const CBlockTreeDB &); diff --git a/src/txdb.cpp b/src/txdb.cpp --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -35,7 +35,7 @@ struct CoinEntry { COutPoint *outpoint; char key; - CoinEntry(const COutPoint *ptr) + explicit CoinEntry(const COutPoint *ptr) : outpoint(const_cast(ptr)), key(DB_COIN) {} template void Serialize(Stream &s) const { diff --git a/src/txmempool.h b/src/txmempool.h --- a/src/txmempool.h +++ b/src/txmempool.h @@ -234,7 +234,7 @@ }; struct update_fee_delta { - update_fee_delta(Amount _feeDelta) : feeDelta(_feeDelta) {} + explicit update_fee_delta(Amount _feeDelta) : feeDelta(_feeDelta) {} void operator()(CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); } @@ -243,7 +243,7 @@ }; struct update_lock_points { - update_lock_points(const LockPoints &_lp) : lp(_lp) {} + explicit update_lock_points(const LockPoints &_lp) : lp(_lp) {} void operator()(CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); } diff --git a/src/uint256.h b/src/uint256.h --- a/src/uint256.h +++ b/src/uint256.h @@ -111,7 +111,7 @@ class uint160 : public base_blob<160> { public: uint160() {} - uint160(const base_blob<160> &b) : base_blob<160>(b) {} + explicit uint160(const base_blob<160> &b) : base_blob<160>(b) {} explicit uint160(const std::vector &vch) : base_blob<160>(vch) {} }; @@ -124,7 +124,7 @@ class uint256 : public base_blob<256> { public: uint256() {} - uint256(const base_blob<256> &b) : base_blob<256>(b) {} + explicit uint256(const base_blob<256> &b) : base_blob<256>(b) {} explicit uint256(const std::vector &vch) : base_blob<256>(vch) {} /** diff --git a/src/undo.h b/src/undo.h --- a/src/undo.h +++ b/src/undo.h @@ -29,7 +29,7 @@ const Coin *pcoin; public: - TxInUndoSerializer(const Coin *pcoinIn) : pcoin(pcoinIn) {} + explicit TxInUndoSerializer(const Coin *pcoinIn) : pcoin(pcoinIn) {} template void Serialize(Stream &s) const { ::Serialize( @@ -46,7 +46,7 @@ Coin *pcoin; public: - TxInUndoDeserializer(Coin *pcoinIn) : pcoin(pcoinIn) {} + explicit TxInUndoDeserializer(Coin *pcoinIn) : pcoin(pcoinIn) {} template void Unserialize(Stream &s) { uint32_t nCode = 0; diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2276,7 +2276,7 @@ CTxMemPool &pool; public: - ConnectTrace(CTxMemPool &_pool) : blocksConnected(1), pool(_pool) { + explicit ConnectTrace(CTxMemPool &_pool) : blocksConnected(1), pool(_pool) { pool.NotifyEntryRemoved.connect( boost::bind(&ConnectTrace::NotifyEntryRemoved, this, _1, _2)); } diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -41,7 +41,7 @@ // our own queue here :( SingleThreadedSchedulerClient m_schedulerClient; - MainSignalsInstance(CScheduler *pscheduler) + explicit MainSignalsInstance(CScheduler *pscheduler) : m_schedulerClient(pscheduler) {} }; diff --git a/src/versionbits.cpp b/src/versionbits.cpp --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -173,7 +173,8 @@ } public: - VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {} + explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) + : id(id_) {} uint32_t Mask(const Consensus::Params ¶ms) const { return ((uint32_t)1) << params.vDeployments[id].bit; } diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -11,7 +11,8 @@ * Testing setup and teardown for wallet. */ struct WalletTestingSetup : public TestingSetup { - WalletTestingSetup(const std::string &chainName = CBaseChainParams::MAIN); + explicit WalletTestingSetup( + const std::string &chainName = CBaseChainParams::MAIN); ~WalletTestingSetup(); }; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -204,7 +204,7 @@ Init(); } - CMerkleTx(CTransactionRef arg) { + explicit CMerkleTx(CTransactionRef arg) { SetTx(std::move(arg)); Init(); } @@ -503,7 +503,7 @@ //! todo: add something to note what created it (user, getnewaddress, //! change) maybe should have a map property map - CWalletKey(int64_t nExpires = 0); + explicit CWalletKey(int64_t nExpires = 0); ADD_SERIALIZE_METHODS; @@ -717,7 +717,7 @@ unsigned int nMasterKeyMaxID; // Create wallet with dummy database handle - CWallet(const CChainParams &chainParamsIn) + explicit CWallet(const CChainParams &chainParamsIn) : dbw(new CWalletDBWrapper()), chainParams(chainParamsIn) { SetNull(); } @@ -1143,7 +1143,7 @@ bool fInternal; public: - CReserveKey(CWallet *pwalletIn) { + explicit CReserveKey(CWallet *pwalletIn) { nIndex = -1; pwallet = pwalletIn; fInternal = false; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -107,7 +107,7 @@ CKeyID hdMasterKeyID; CKeyMetadata() { SetNull(); } - CKeyMetadata(int64_t nCreateTime_) { + explicit CKeyMetadata(int64_t nCreateTime_) { SetNull(); nCreateTime = nCreateTime_; } @@ -159,8 +159,8 @@ } public: - CWalletDB(CWalletDBWrapper &dbw, const char *pszMode = "r+", - bool _fFlushOnClose = true) + explicit CWalletDB(CWalletDBWrapper &dbw, const char *pszMode = "r+", + bool _fFlushOnClose = true) : batch(dbw, pszMode, _fFlushOnClose), m_dbw(dbw) {} bool WriteName(const CTxDestination &address, const std::string &strName);