diff --git a/src/addrdb.h b/src/addrdb.h index 70eb0badf960d..ba9c9c2c1929a 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -39,7 +39,7 @@ class CBanEntry SetNull(); } - CBanEntry(int64_t nCreateTimeIn) + explicit CBanEntry(int64_t nCreateTimeIn) { SetNull(); nCreateTime = nCreateTimeIn; diff --git a/src/blockassembler.h b/src/blockassembler.h index 0db38ebd3f68b..f6deee567d989 100644 --- a/src/blockassembler.h +++ b/src/blockassembler.h @@ -34,7 +34,7 @@ struct CBlockTemplate // 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(); @@ -117,7 +117,7 @@ typedef indexed_modified_transaction_set::index::type::iterator 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) { diff --git a/src/bls/bls_worker.h b/src/bls/bls_worker.h index c61034a36b26d..2ffdb9cca12cf 100644 --- a/src/bls/bls_worker.h +++ b/src/bls/bls_worker.h @@ -156,7 +156,7 @@ class CBLSWorkerCache std::map > publicKeyShareCache; public: - CBLSWorkerCache(CBLSWorker& _worker) : + explicit CBLSWorkerCache(CBLSWorker& _worker) : worker(_worker) {} BLSVerificationVectorPtr BuildQuorumVerificationVector(const uint256& cacheKey, const std::vector& vvecs) diff --git a/src/chain.h b/src/chain.h index d12f7f73632fa..bc38aa1440706 100644 --- a/src/chain.h +++ b/src/chain.h @@ -205,7 +205,7 @@ class CBlockIndex unsigned int nTimeMax{0}; CBlockIndex() {} - CBlockIndex(const CBlock& block); + explicit CBlockIndex(const CBlock& block); std::string ToString() const; diff --git a/src/chainparams.h b/src/chainparams.h index 18ef2ceccd682..be9851d3c6c73 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -20,7 +20,7 @@ struct CDNSSeedData { std::string host; bool supportsServiceBitsFiltering; - CDNSSeedData(const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {} + explicit CDNSSeedData(const std::string& strHost, bool supportsServiceBitsFilteringIn = false) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {} }; typedef std::map MapCheckpoints; diff --git a/src/checkqueue.h b/src/checkqueue.h index 3e892ef91c382..8d80bf22c3fc8 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -175,7 +175,7 @@ class CCheckQueueControl bool fDone; public: - CCheckQueueControl(CCheckQueue* pqueueIn) : pqueue(pqueueIn), fDone(false) + explicit CCheckQueueControl(CCheckQueue* pqueueIn) : pqueue(pqueueIn), fDone(false) { // passed queue is supposed to be unused, or nullptr if (pqueue != nullptr) { diff --git a/src/crypto/aes.h b/src/crypto/aes.h index 3b852c1bedc68..8eabfed54bd65 100644 --- a/src/crypto/aes.h +++ b/src/crypto/aes.h @@ -22,7 +22,7 @@ class AES128Encrypt AES128_ctx ctx; public: - AES128Encrypt(const unsigned char key[16]); + explicit AES128Encrypt(const unsigned char key[16]); ~AES128Encrypt(); void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const; }; @@ -34,7 +34,7 @@ class AES128Decrypt AES128_ctx ctx; public: - AES128Decrypt(const unsigned char key[16]); + explicit AES128Decrypt(const unsigned char key[16]); ~AES128Decrypt(); void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const; }; @@ -46,7 +46,7 @@ class AES256Encrypt AES256_ctx ctx; public: - AES256Encrypt(const unsigned char key[32]); + explicit AES256Encrypt(const unsigned char key[32]); ~AES256Encrypt(); void Encrypt(unsigned char ciphertext[16], const unsigned char plaintext[16]) const; }; @@ -58,7 +58,7 @@ class AES256Decrypt AES256_ctx ctx; public: - AES256Decrypt(const unsigned char key[32]); + explicit AES256Decrypt(const unsigned char key[32]); ~AES256Decrypt(); void Decrypt(unsigned char plaintext[16], const unsigned char ciphertext[16]) const; }; diff --git a/src/ctpl_stl.h b/src/ctpl_stl.h index 7d4de240e38db..0dcf115f585b5 100644 --- a/src/ctpl_stl.h +++ b/src/ctpl_stl.h @@ -73,7 +73,7 @@ namespace ctpl { public: thread_pool() { this->init(); } - thread_pool(int nThreads) { this->init(); this->resize(nThreads); } + explicit thread_pool(int nThreads) { this->init(); this->resize(nThreads); } // the destructor waits for all the functions in the queue to be finished ~thread_pool() { diff --git a/src/cxxtimer.h b/src/cxxtimer.h index cee63357f7dcb..569051275dadc 100644 --- a/src/cxxtimer.h +++ b/src/cxxtimer.h @@ -45,7 +45,7 @@ class Timer { * If true, the timer is started just after construction. * Otherwise, it will not be automatically started. */ - Timer(bool start = false); + explicit Timer(bool start = false); /** * Copy constructor. diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 31cb6a2d3f87e..35e0177d323b7 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -25,7 +25,7 @@ static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024; 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; diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index e2c981f86dd8d..485c33dd86d4f 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -184,7 +184,7 @@ class CDeterministicMN public: CDeterministicMN() = delete; // no default constructor, must specify internalId - CDeterministicMN(uint64_t _internalId) : internalId(_internalId) + explicit CDeterministicMN(uint64_t _internalId) : internalId(_internalId) { // only non-initial values assert(_internalId != std::numeric_limits::max()); diff --git a/src/hash.h b/src/hash.h index 7d4df0ff5090e..20066ab5e6fd7 100644 --- a/src/hash.h +++ b/src/hash.h @@ -257,7 +257,7 @@ class CHashVerifier : public CHashWriter Source* source; public: - CHashVerifier(Source* source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {} + explicit CHashVerifier(Source* source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {} void read(char* pch, size_t nSize) { diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 6adb8a01b2c29..d8869432df363 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -40,7 +40,7 @@ class HTTPRPCTimer : public RPCTimerBase class HTTPRPCTimerInterface : public RPCTimerInterface { public: - HTTPRPCTimerInterface(struct event_base* base) : base(base) + explicit HTTPRPCTimerInterface(struct event_base* base) : base(base) { } const char* Name() diff --git a/src/httpserver.h b/src/httpserver.h index d9bc4c13cd377..0a4e65dfb1f73 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -62,7 +62,7 @@ class HTTPRequest bool replySent; public: - HTTPRequest(struct evhttp_request* req); + explicit HTTPRequest(struct evhttp_request* req); ~HTTPRequest(); enum RequestMethod { diff --git a/src/init.cpp b/src/init.cpp index 3ab4e8b041c92..1f048594724a3 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -160,7 +160,7 @@ NODISCARD static bool CreatePidFile() class CCoinsViewErrorCatcher : public CCoinsViewBacked { public: - CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {} + explicit CCoinsViewErrorCatcher(CCoinsView* view) : CCoinsViewBacked(view) {} bool GetCoin(const COutPoint& outpoint, Coin& coin) const override { try { diff --git a/src/key_io.cpp b/src/key_io.cpp index 664e52f63fcda..6eaa57636951d 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -22,7 +22,7 @@ namespace const CChainParams::Base58Type m_addrType; public: - DestinationEncoder(const CChainParams& params, const CChainParams::Base58Type _addrType = CChainParams::PUBKEY_ADDRESS) : m_params(params), m_addrType(_addrType) {} + explicit DestinationEncoder(const CChainParams& params, const CChainParams::Base58Type _addrType = CChainParams::PUBKEY_ADDRESS) : m_params(params), m_addrType(_addrType) {} std::string operator()(const CKeyID& id) const { diff --git a/src/libzerocoin/Coin.h b/src/libzerocoin/Coin.h index 9d2423d1e81fc..400071bfa66df 100644 --- a/src/libzerocoin/Coin.h +++ b/src/libzerocoin/Coin.h @@ -30,7 +30,7 @@ namespace libzerocoin class InvalidSerialException : public std::exception { public: std::string message; - InvalidSerialException(const std::string &message) : message(message) {} + explicit InvalidSerialException(const std::string &message) : message(message) {} }; int ExtractVersionFromSerial(const CBigNum& bnSerial); @@ -54,7 +54,7 @@ class PublicCoin strm >> *this; } - PublicCoin(const ZerocoinParams* p); + explicit PublicCoin(const ZerocoinParams* p); /**Generates a public coin * diff --git a/src/libzerocoin/CoinRandomnessSchnorrSignature.h b/src/libzerocoin/CoinRandomnessSchnorrSignature.h index 2635e70bb91c2..242584935dc5a 100644 --- a/src/libzerocoin/CoinRandomnessSchnorrSignature.h +++ b/src/libzerocoin/CoinRandomnessSchnorrSignature.h @@ -19,7 +19,7 @@ namespace libzerocoin { class CoinRandomnessSchnorrSignature { public: CoinRandomnessSchnorrSignature() {}; - template CoinRandomnessSchnorrSignature(Stream& strm) {strm >> *this;} + template explicit CoinRandomnessSchnorrSignature(Stream& strm) {strm >> *this;} /** Creates a Schnorr signature object using the randomness of a public coin as private key sk. * diff --git a/src/libzerocoin/CoinSpend.h b/src/libzerocoin/CoinSpend.h index d8174c2547eb5..7bb3a5b2ad4b8 100644 --- a/src/libzerocoin/CoinSpend.h +++ b/src/libzerocoin/CoinSpend.h @@ -80,7 +80,7 @@ class CoinSpend public: CoinSpend() {}; - CoinSpend(CDataStream& strm) { strm >> *this; } + explicit CoinSpend(CDataStream& strm) { strm >> *this; } virtual ~CoinSpend(){}; const CBigNum& getCoinSerialNumber() const { return this->coinSerialNumber; } diff --git a/src/libzerocoin/Params.h b/src/libzerocoin/Params.h index 9b87817e2da11..224a73d9be422 100644 --- a/src/libzerocoin/Params.h +++ b/src/libzerocoin/Params.h @@ -156,8 +156,7 @@ class ZerocoinParams { * compromised. The integer "N" must be a MINIMUM of 1024 * in length. 3072 bits is strongly recommended. **/ - ZerocoinParams(CBigNum accumulatorModulus, - uint32_t securityLevel = ZEROCOIN_DEFAULT_SECURITYLEVEL); + explicit ZerocoinParams(CBigNum accumulatorModulus, uint32_t securityLevel = ZEROCOIN_DEFAULT_SECURITYLEVEL); bool initialized; diff --git a/src/limitedmap.h b/src/limitedmap.h index 5af2be122c7f1..1700a11d086e9 100644 --- a/src/limitedmap.h +++ b/src/limitedmap.h @@ -28,7 +28,7 @@ class limitedmap size_type nMaxSize; public: - limitedmap(size_type nMaxSizeIn = 0) { nMaxSize = nMaxSizeIn; } + explicit limitedmap(size_type nMaxSizeIn = 0) { nMaxSize = nMaxSizeIn; } const_iterator begin() const { return map.begin(); } const_iterator end() const { return map.end(); } size_type size() const { return map.size(); } diff --git a/src/llmq/quorums_chainlocks.h b/src/llmq/quorums_chainlocks.h index 06d444cf49e35..0143cfdf45cda 100644 --- a/src/llmq/quorums_chainlocks.h +++ b/src/llmq/quorums_chainlocks.h @@ -62,7 +62,7 @@ class CChainLocksHandler : public CRecoveredSigsListener int64_t lastCleanupTime{0}; public: - CChainLocksHandler(CScheduler* _scheduler); + explicit CChainLocksHandler(CScheduler* _scheduler); ~CChainLocksHandler(); void Start(); void Stop(); diff --git a/src/llmq/quorums_dkgsession.h b/src/llmq/quorums_dkgsession.h index c7c546d79e1f0..dac33237aeeac 100644 --- a/src/llmq/quorums_dkgsession.h +++ b/src/llmq/quorums_dkgsession.h @@ -95,7 +95,7 @@ class CDKGComplaint public: CDKGComplaint() {} - CDKGComplaint(const Consensus::LLMQParams& params); + explicit CDKGComplaint(const Consensus::LLMQParams& params); SERIALIZE_METHODS(CDKGComplaint, obj) { @@ -163,7 +163,7 @@ class CDKGPrematureCommitment public: CDKGPrematureCommitment() {} - CDKGPrematureCommitment(const Consensus::LLMQParams& params); + explicit CDKGPrematureCommitment(const Consensus::LLMQParams& params); int CountValidMembers() const { diff --git a/src/llmq/quorums_dkgsessionhandler.h b/src/llmq/quorums_dkgsessionhandler.h index d745938b9cc8d..01fda2541333f 100644 --- a/src/llmq/quorums_dkgsessionhandler.h +++ b/src/llmq/quorums_dkgsessionhandler.h @@ -45,7 +45,7 @@ class CDKGPendingMessages std::set seenMessages; public: - CDKGPendingMessages(size_t _maxMessagesPerNode); + explicit CDKGPendingMessages(size_t _maxMessagesPerNode); void PushPendingMessage(NodeId from, CDataStream& vRecv, int invType); std::list PopPendingMessages(size_t maxCount); diff --git a/src/llmq/quorums_signing.h b/src/llmq/quorums_signing.h index a68bded653b3f..ea82b1d08a8bf 100644 --- a/src/llmq/quorums_signing.h +++ b/src/llmq/quorums_signing.h @@ -79,7 +79,7 @@ class CRecoveredSigsDb unordered_lru_cache hasSigForHashCache; public: - CRecoveredSigsDb(CDBWrapper& _db); + explicit CRecoveredSigsDb(CDBWrapper& _db); bool HasRecoveredSig(Consensus::LLMQType llmqType, const uint256& id, const uint256& msgHash); bool HasRecoveredSigForId(Consensus::LLMQType llmqType, const uint256& id); diff --git a/src/masternode-payments.h b/src/masternode-payments.h index 9c09b80d70639..b61533359110c 100644 --- a/src/masternode-payments.h +++ b/src/masternode-payments.h @@ -95,7 +95,7 @@ class CMasternodeBlockPayees nBlockHeight = 0; vecPayments.clear(); } - CMasternodeBlockPayees(int nBlockHeightIn) + explicit CMasternodeBlockPayees(int nBlockHeightIn) { nBlockHeight = nBlockHeightIn; vecPayments.clear(); diff --git a/src/masternode.h b/src/masternode.h index 0bcad4ab83946..b35027cbd6d46 100644 --- a/src/masternode.h +++ b/src/masternode.h @@ -244,7 +244,7 @@ class CMasternodeBroadcast : public CMasternode public: CMasternodeBroadcast(); CMasternodeBroadcast(CService newAddr, CTxIn newVin, CPubKey newPubkey, CPubKey newPubkey2, int protocolVersionIn, const CMasternodePing& _lastPing); - CMasternodeBroadcast(const CMasternode& mn); + explicit CMasternodeBroadcast(const CMasternode& mn); bool CheckAndUpdate(int& nDoS); diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a4539fab60cbd..a2e12b8c69f12 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2361,7 +2361,7 @@ class CompareInvMempoolOrder { CTxMemPool *mp; public: - CompareInvMempoolOrder(CTxMemPool *_mempool) + explicit CompareInvMempoolOrder(CTxMemPool *_mempool) { mp = _mempool; } diff --git a/src/net_processing.h b/src/net_processing.h index cae09432306a4..35f2e83b566f0 100644 --- a/src/net_processing.h +++ b/src/net_processing.h @@ -37,7 +37,7 @@ class PeerLogicValidation : public CValidationInterface, public NetEventsInterfa CConnman* connman; public: - PeerLogicValidation(CConnman* connman); + explicit PeerLogicValidation(CConnman* connman); ~PeerLogicValidation() = default; void BlockConnected(const std::shared_ptr& pblock, const CBlockIndex* pindex) override; diff --git a/src/netaddress.h b/src/netaddress.h index 22fc37b61391a..0f28d75e09d11 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -204,7 +204,7 @@ class CNetAddr std::vector GetAddrBytes() 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); @@ -489,7 +489,7 @@ class CService : public CNetAddr CService(); CService(const CNetAddr& ip, uint16_t port); CService(const struct in_addr& ipv4Addr, uint16_t port); - CService(const struct sockaddr_in& addr); + explicit CService(const struct sockaddr_in& addr); uint16_t GetPort() const; bool GetSockAddr(struct sockaddr* paddr, socklen_t* addrlen) const; bool SetSockAddr(const struct sockaddr* paddr); @@ -502,7 +502,7 @@ class CService : public CNetAddr std::string ToStringIPPort() const; CService(const struct in6_addr& ipv6Addr, uint16_t port); - CService(const struct sockaddr_in6& addr); + explicit CService(const struct sockaddr_in6& addr); SERIALIZE_METHODS(CService, obj) { diff --git a/src/netbase.h b/src/netbase.h index b7667550beffe..02c8dd2c48a1d 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -30,7 +30,7 @@ class proxyType { public: proxyType(): randomize_credentials(false) {} - proxyType(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {} + explicit proxyType(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {} bool IsValid() const { return proxy.IsValid(); } diff --git a/src/netmessagemaker.h b/src/netmessagemaker.h index 48daadbc01462..381c71042d78b 100644 --- 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, Args&&... args) diff --git a/src/operationresult.h b/src/operationresult.h index 251565996bed1..6a02b982f37c7 100644 --- a/src/operationresult.h +++ b/src/operationresult.h @@ -36,8 +36,8 @@ class CallResult : public OperationResult Optional m_obj_res{nullopt}; public: CallResult() : OperationResult(false) {} - CallResult(T _obj) : OperationResult(true), m_obj_res(_obj) { } - CallResult(const std::string& error) : OperationResult(false, error) { } + explicit CallResult(T _obj) : OperationResult(true), m_obj_res(_obj) { } + explicit CallResult(const std::string& error) : OperationResult(false, error) { } const Optional& getObjResult() const { return m_obj_res; } }; diff --git a/src/policy/fees.h b/src/policy/fees.h index 0001d99b5db7a..b8d0cd818c340 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -201,7 +201,7 @@ class CBlockPolicyEstimator { public: /** Create new BlockPolicyEstimator and initialize stats tracking classes with default values */ - CBlockPolicyEstimator(const CFeeRate& minRelayFee); + explicit CBlockPolicyEstimator(const CFeeRate& minRelayFee); /** Process all the transactions that have been included in a block */ void processBlock(unsigned int nBlockHeight, diff --git a/src/primitives/block.h b/src/primitives/block.h index a46563307411d..edd474d2497a6 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -156,7 +156,7 @@ struct CBlockLocator CBlockLocator() {} - CBlockLocator(const std::vector& vHaveIn) + explicit CBlockLocator(const std::vector& vHaveIn) { vHave = vHaveIn; } diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 425cd71e11b5e..21cc7216a1412 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -39,7 +39,7 @@ class GUIException : public std::exception { public: std::string message; - GUIException(const std::string &message) : message(message) {} + explicit GUIException(const std::string &message) : message(message) {} }; /** Utility functions used by the PIVX Qt UI. diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index ec8ca3f9c8d13..996cebd1ddd51 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -44,7 +44,7 @@ class FreespaceChecker : public QObject Q_OBJECT public: - FreespaceChecker(Intro* intro); + explicit FreespaceChecker(Intro* intro); enum Status { ST_OK, diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp index 867fd86e3f4d2..8739c57e292d1 100644 --- a/src/qt/notificator.cpp +++ b/src/qt/notificator.cpp @@ -70,7 +70,7 @@ class FreedesktopImage { public: FreedesktopImage() {} - FreedesktopImage(const QImage& img); + explicit FreedesktopImage(const QImage& img); static int metaType(); diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 9438ddd547c3b..a98376ef3027e 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -65,7 +65,7 @@ class PaymentServer : public QObject static bool ipcSendCommandLine(); // parent should be QApplication object - PaymentServer(QObject* parent, bool startLocalServer = true); + explicit PaymentServer(QObject* parent, bool startLocalServer = true); ~PaymentServer(); // OptionsModel is used for getting proxy settings and display unit diff --git a/src/qt/pivx/pfborderimage.h b/src/qt/pivx/pfborderimage.h index e0c4d875834c2..e7a4d5a0e4bd2 100644 --- a/src/qt/pivx/pfborderimage.h +++ b/src/qt/pivx/pfborderimage.h @@ -15,7 +15,7 @@ class PFBorderImage : public QFrame Q_OBJECT public: - PFBorderImage(QWidget *parent = nullptr) : QFrame(parent) {}; + explicit PFBorderImage(QWidget *parent = nullptr) : QFrame(parent) {}; ~PFBorderImage() {}; #if defined(Q_OS_MAC) diff --git a/src/qt/pivx/pwidget.cpp b/src/qt/pivx/pwidget.cpp index 61ea72473d034..38b0a8b2fdf83 100644 --- a/src/qt/pivx/pwidget.cpp +++ b/src/qt/pivx/pwidget.cpp @@ -71,7 +71,7 @@ void PWidget::emitMessage(const QString& title, const QString& body, unsigned in class WorkerTask : public QRunnable { public: - WorkerTask(QPointer worker) { + explicit WorkerTask(QPointer worker) { this->worker = worker; } diff --git a/src/qt/transactionrecord.h b/src/qt/transactionrecord.h index d984f305c8cd2..3858704802d03 100644 --- a/src/qt/transactionrecord.h +++ b/src/qt/transactionrecord.h @@ -108,7 +108,7 @@ class TransactionRecord /** Number of confirmation recommended for accepting a transaction */ static const int RecommendedNumConfirmations = 6; - TransactionRecord(unsigned int size) : hash(), time(0), type(Other), address(""), debit(0), credit(0), size(size), idx(0) + explicit TransactionRecord(unsigned int size) : hash(), time(0), type(Other), address(""), debit(0), credit(0), size(size), idx(0) { } diff --git a/src/qt/utilitydialog.h b/src/qt/utilitydialog.h index caffa8fce16ea..9982e252d08ae 100644 --- a/src/qt/utilitydialog.h +++ b/src/qt/utilitydialog.h @@ -41,7 +41,7 @@ class ShutdownWindow : public QWidget Q_OBJECT public: - ShutdownWindow(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::Widget); + explicit ShutdownWindow(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::Widget); static void showShutdownWindow(QMainWindow* window); protected: diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index b9112b65a7b76..0330d07101e90 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -192,7 +192,7 @@ class WalletModel : public QObject // Return status record for SendCoins, contains error id + information struct SendCoinsReturn { SendCoinsReturn(StatusCode status = OK) : status(status) {} - SendCoinsReturn(CWallet::CommitResult _commitRes) : commitRes(_commitRes) + explicit SendCoinsReturn(CWallet::CommitResult _commitRes) : commitRes(_commitRes) { status = (_commitRes.status == CWallet::CommitStatus::OK ? OK : TransactionCommitFailed); } diff --git a/src/rest.cpp b/src/rest.cpp index d2d71e1a87307..dd318f457ed9a 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -47,7 +47,7 @@ struct CCoin { CTxOut out; CCoin() : nHeight(0) {} - CCoin(Coin&& in) : nHeight(in.nHeight), out(std::move(in.out)) {} + explicit CCoin(Coin&& in) : nHeight(in.nHeight), out(std::move(in.out)) {} SERIALIZE_METHODS(CCoin, obj) { diff --git a/src/reverse_iterate.h b/src/reverse_iterate.h index 1c86b7e10c92c..958de747c1654 100644 --- a/src/reverse_iterate.h +++ b/src/reverse_iterate.h @@ -19,7 +19,7 @@ class reverse_range T &m_x; public: - reverse_range(T &x) : m_x(x) {} + explicit reverse_range(T &x) : m_x(x) {} auto begin() const -> decltype(this->m_x.rbegin()) { diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a84634b276e41..8b8d46fba8ed7 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -231,7 +231,7 @@ class DescribeAddressVisitor : public boost::static_visitor 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/sapling/address.h b/src/sapling/address.h index 701b3234d1555..29cdc99691ee2 100644 --- a/src/sapling/address.h +++ b/src/sapling/address.h @@ -52,7 +52,7 @@ class SaplingPaymentAddress { class SaplingIncomingViewingKey : public uint256 { public: SaplingIncomingViewingKey() : uint256() { } - SaplingIncomingViewingKey(uint256 ivk) : uint256(ivk) { } + explicit SaplingIncomingViewingKey(uint256 ivk) : uint256(ivk) { } // Can pass in diversifier for Sapling addr Optional address(diversifier_t d) const; @@ -113,7 +113,7 @@ class SaplingExpandedSpendingKey { class SaplingSpendingKey : public uint256 { public: SaplingSpendingKey() : uint256() { } - SaplingSpendingKey(uint256 sk) : uint256(sk) { } + explicit SaplingSpendingKey(uint256 sk) : uint256(sk) { } static SaplingSpendingKey random(); diff --git a/src/sapling/incrementalmerkletree.cpp b/src/sapling/incrementalmerkletree.cpp index 0be875878758b..72f4f636dfe65 100644 --- a/src/sapling/incrementalmerkletree.cpp +++ b/src/sapling/incrementalmerkletree.cpp @@ -849,7 +849,7 @@ class PathFiller { static EmptyMerkleRoots emptyroots; public: PathFiller() : queue() { } - PathFiller(std::deque queue) : queue(queue) { } + explicit PathFiller(std::deque queue) : queue(queue) { } Hash next(size_t depth) { if (queue.size() > 0) { diff --git a/src/sapling/incrementalmerkletree.h b/src/sapling/incrementalmerkletree.h index 445ec090e794c..dcdb4cec2c91a 100644 --- a/src/sapling/incrementalmerkletree.h +++ b/src/sapling/incrementalmerkletree.h @@ -193,7 +193,7 @@ friend class IncrementalMerkleTree; Optional> cursor; size_t cursor_depth = 0; std::deque partial_path() const; - IncrementalWitness(IncrementalMerkleTree tree) : tree(tree) {} + explicit IncrementalWitness(IncrementalMerkleTree tree) : tree(tree) {} }; template diff --git a/src/sapling/key_io_sapling.cpp b/src/sapling/key_io_sapling.cpp index 5834fe336a986..a1bdf94807315 100644 --- a/src/sapling/key_io_sapling.cpp +++ b/src/sapling/key_io_sapling.cpp @@ -23,7 +23,7 @@ class PaymentAddressEncoder : public boost::static_visitor const CChainParams& m_params; public: - PaymentAddressEncoder(const CChainParams& params) : m_params(params) {} + explicit PaymentAddressEncoder(const CChainParams& params) : m_params(params) {} std::string operator()(const libzcash::SaplingPaymentAddress& zaddr) const { @@ -47,7 +47,7 @@ class ViewingKeyEncoder : public boost::static_visitor const CChainParams& m_params; public: - ViewingKeyEncoder(const CChainParams& params) : m_params(params) {} + explicit ViewingKeyEncoder(const CChainParams& params) : m_params(params) {} std::string operator()(const libzcash::SaplingExtendedFullViewingKey& extfvk) const { @@ -74,7 +74,7 @@ class SpendingKeyEncoder : public boost::static_visitor const CChainParams& m_params; public: - SpendingKeyEncoder(const CChainParams& params) : m_params(params) {} + explicit SpendingKeyEncoder(const CChainParams& params) : m_params(params) {} std::string operator()(const libzcash::SaplingExtendedSpendingKey& zkey) const { diff --git a/src/sapling/note.h b/src/sapling/note.h index 3af0168334c0b..f450893c9e91a 100644 --- a/src/sapling/note.h +++ b/src/sapling/note.h @@ -24,7 +24,7 @@ class BaseNote { uint64_t value_{0}; public: BaseNote() {} - BaseNote(uint64_t value) : value_(value) {}; + explicit BaseNote(uint64_t value) : value_(value) {}; virtual ~BaseNote() {}; inline uint64_t value() const { return value_; }; diff --git a/src/sapling/sapling_operation.h b/src/sapling/sapling_operation.h index 71abffd1547f6..34c20a5960d0c 100644 --- a/src/sapling/sapling_operation.h +++ b/src/sapling/sapling_operation.h @@ -62,7 +62,7 @@ struct SendManyRecipient {} // Transparent recipient: OP_RETURN - SendManyRecipient(const uint256& message): + explicit SendManyRecipient(const uint256& message): recipient(new CRecipient(GetScriptForOpReturn(message), 0, false)) {} }; diff --git a/src/sapling/saplingscriptpubkeyman.h b/src/sapling/saplingscriptpubkeyman.h index 9fec1850e0b6f..1f06697a0068d 100644 --- a/src/sapling/saplingscriptpubkeyman.h +++ b/src/sapling/saplingscriptpubkeyman.h @@ -45,7 +45,7 @@ class SaplingNoteData public: SaplingNoteData() : nullifier() { } - SaplingNoteData(const libzcash::SaplingIncomingViewingKey& _ivk) : ivk {_ivk}, nullifier() { } + explicit SaplingNoteData(const libzcash::SaplingIncomingViewingKey& _ivk) : ivk {_ivk}, nullifier() { } SaplingNoteData(const libzcash::SaplingIncomingViewingKey& _ivk, const uint256& n) : ivk {_ivk}, nullifier(n) { } /* witnesses/ivk: only for own (received) outputs */ @@ -147,7 +147,7 @@ typedef std::map mapSaplingNoteData_t; class SaplingScriptPubKeyMan { public: - SaplingScriptPubKeyMan(CWallet *parent) : wallet(parent) {} + explicit SaplingScriptPubKeyMan(CWallet *parent) : wallet(parent) {} ~SaplingScriptPubKeyMan() {}; diff --git a/src/sapling/transaction_builder.h b/src/sapling/transaction_builder.h index c3993fef81985..ba6b28e84afda 100644 --- a/src/sapling/transaction_builder.h +++ b/src/sapling/transaction_builder.h @@ -71,8 +71,8 @@ class TransactionBuilderResult { Optional maybeError; public: TransactionBuilderResult() = delete; - TransactionBuilderResult(const CTransaction& tx); - TransactionBuilderResult(const std::string& error); + explicit TransactionBuilderResult(const CTransaction& tx); + explicit TransactionBuilderResult(const std::string& error); bool IsTx(); bool IsError(); CTransaction GetTxOrThrow(); @@ -96,7 +96,7 @@ class TransactionBuilder Optional tChangeAddr; public: - TransactionBuilder( + explicit TransactionBuilder( const Consensus::Params& consensusParams, CKeyStore* keyStore = nullptr); diff --git a/src/sapling/zip32.h b/src/sapling/zip32.h index 07d4626cda929..92b128bff4de0 100644 --- a/src/sapling/zip32.h +++ b/src/sapling/zip32.h @@ -23,7 +23,7 @@ class HDSeed { public: HDSeed() {} - HDSeed(const CPrivKey& seedIn) : seed(seedIn) {} + explicit HDSeed(const CPrivKey& seedIn) : seed(seedIn) {} static HDSeed Random(size_t len = 32); bool IsNull() const { return seed.empty(); }; diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index e5476a83a91ce..e254a9fcdd501 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -63,7 +63,7 @@ class ConstPubkeyProvider final : public PubkeyProvider CPubKey m_pubkey; public: - ConstPubkeyProvider(const CPubKey& pubkey) : m_pubkey(pubkey) {} + explicit ConstPubkeyProvider(const CPubKey& pubkey) : m_pubkey(pubkey) {} bool GetPubKey(int pos, const SigningProvider& arg, CPubKey& out) const override { out = m_pubkey; @@ -170,7 +170,7 @@ class AddressDescriptor final : public Descriptor CTxDestination m_destination; public: - AddressDescriptor(CTxDestination destination) : m_destination(std::move(destination)) {} + explicit AddressDescriptor(CTxDestination destination) : m_destination(std::move(destination)) {} bool IsRange() const override { return false; } std::string ToString() const override { return "addr(" + EncodeDestination(m_destination) + ")"; } @@ -188,7 +188,7 @@ class RawDescriptor final : public Descriptor CScript m_script; public: - RawDescriptor(CScript script) : m_script(std::move(script)) {} + explicit RawDescriptor(CScript script) : m_script(std::move(script)) {} bool IsRange() const override { return false; } std::string ToString() const override { return "raw(" + HexStr(m_script) + ")"; } @@ -328,7 +328,7 @@ class ComboDescriptor final : public Descriptor std::unique_ptr m_provider; public: - ComboDescriptor(std::unique_ptr provider) : m_provider(std::move(provider)) {} + explicit ComboDescriptor(std::unique_ptr provider) : m_provider(std::move(provider)) {} bool IsRange() const override { return m_provider->IsRange(); } std::string ToString() const override { return "combo(" + m_provider->ToString() + ")"; } diff --git a/src/script/interpreter.h b/src/script/interpreter.h index e261299a3f526..628d641173ea3 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -93,7 +93,7 @@ struct PrecomputedTransactionData { uint256 hashPrevouts, hashSequence, hashOutputs, hashShieldedSpends, hashShieldedOutputs; - PrecomputedTransactionData(const CTransaction& tx); + explicit PrecomputedTransactionData(const CTransaction& tx); }; uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache = nullptr); diff --git a/src/script/ismine.cpp b/src/script/ismine.cpp index 3c9700e09b3f6..be1f89ddf3b05 100644 --- a/src/script/ismine.cpp +++ b/src/script/ismine.cpp @@ -54,7 +54,7 @@ namespace private: const CKeyStore& keystore; public: - CWDestinationVisitor(const CKeyStore& _keystore) : keystore(_keystore) {} + explicit CWDestinationVisitor(const CKeyStore& _keystore) : keystore(_keystore) {} isminetype operator()(const CTxDestination& dest) const { return ::IsMine(keystore, dest); diff --git a/src/script/script.h b/src/script/script.h index bb34d24dd9913..56f7618bf76c8 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -415,7 +415,7 @@ class CScript : public CScriptBase return ret; } - CScript(int64_t b) { operator<<(b); } + explicit CScript(int64_t b) { operator<<(b); } explicit CScript(opcodetype b) { operator<<(b); } explicit CScript(const CScriptNum& b) { operator<<(b); } diff --git a/src/script/sign.h b/src/script/sign.h index fa85a0eca73ab..1d8d6d7e4d39d 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -36,7 +36,7 @@ class PublicOnlySigningProvider : public SigningProvider const SigningProvider* m_provider; public: - PublicOnlySigningProvider(const SigningProvider* provider) : m_provider(provider) {} + explicit PublicOnlySigningProvider(const SigningProvider* provider) : m_provider(provider) {} bool GetCScript(const CScriptID &scriptid, CScript& script) const; bool GetPubKey(const CKeyID &address, CPubKey& pubkey) const; }; @@ -60,7 +60,7 @@ class BaseSignatureCreator { 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; @@ -93,7 +93,7 @@ class MutableTransactionSignatureCreator : public TransactionSignatureCreator { /** A signature creator that just produces 72-byte empty signatyres. */ class DummySignatureCreator : public BaseSignatureCreator { public: - DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {} + explicit DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {} const BaseSignatureChecker& Checker() const; bool CreateSig(std::vector& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const; }; diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 559ca76009646..06b169641d334 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -248,7 +248,7 @@ class CScriptVisitor : public boost::static_visitor private: 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/sporkdb.h b/src/sporkdb.h index f36e7ca013307..4f0f5e8290031 100644 --- a/src/sporkdb.h +++ b/src/sporkdb.h @@ -12,7 +12,7 @@ class CSporkDB : public CDBWrapper { public: - CSporkDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); + explicit CSporkDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); private: CSporkDB(const CSporkDB&); diff --git a/src/support/allocators/mt_pooled_secure.h b/src/support/allocators/mt_pooled_secure.h index a25f2321445d1..6924285f94043 100644 --- a/src/support/allocators/mt_pooled_secure.h +++ b/src/support/allocators/mt_pooled_secure.h @@ -26,7 +26,7 @@ struct mt_pooled_secure_allocator : public std::allocator { typedef typename base::reference reference; typedef typename base::const_reference const_reference; typedef typename base::value_type value_type; - mt_pooled_secure_allocator(size_type nrequested_size = 32, + explicit mt_pooled_secure_allocator(size_type nrequested_size = 32, size_type nnext_size = 32, size_type nmax_size = 0) throw() { diff --git a/src/support/allocators/pooled_secure.h b/src/support/allocators/pooled_secure.h index 7db89f1dc8540..9652e339d15f4 100644 --- a/src/support/allocators/pooled_secure.h +++ b/src/support/allocators/pooled_secure.h @@ -29,7 +29,7 @@ struct pooled_secure_allocator : public std::allocator { typedef typename base::reference reference; typedef typename base::const_reference const_reference; typedef typename base::value_type value_type; - pooled_secure_allocator(const size_type nrequested_size = 32, + explicit pooled_secure_allocator(const size_type nrequested_size = 32, const size_type nnext_size = 32, const size_type nmax_size = 0) throw() : pool(nrequested_size, nnext_size, nmax_size){} diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index dd7be8d6e3cd5..89ed79af9aea9 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -160,7 +160,7 @@ class LockedPool * If this callback is provided and returns false, 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 = 0); + explicit LockedPool(std::unique_ptr allocator, LockingFailed_Callback lf_cb_in = 0); ~LockedPool(); LockedPool(const LockedPool& other) = delete; // non construction-copyable @@ -227,7 +227,7 @@ class LockedPoolManager : public LockedPool } 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 index 631032e09460d..3130440e75ed0 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -91,7 +91,7 @@ class TestAddrTypeVisitor : public boost::static_visitor private: std::string exp_addrType; public: - TestAddrTypeVisitor(const std::string &exp_addrType) : exp_addrType(exp_addrType) { } + explicit TestAddrTypeVisitor(const std::string &exp_addrType) : exp_addrType(exp_addrType) { } bool operator()(const CKeyID &id) const { return (exp_addrType == "pubkey"); @@ -116,7 +116,7 @@ class TestPayloadVisitor : public boost::static_visitor private: std::vector exp_payload; public: - TestPayloadVisitor(std::vector &exp_payload) : exp_payload(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 index 3fb86d2d504b1..614b752f14ef9 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -22,7 +22,7 @@ struct TestVector { 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) { vDerive.emplace_back(); diff --git a/src/test/bls_tests.cpp b/src/test/bls_tests.cpp index 501e088c77a3c..e0ec8fab2dd08 100644 --- a/src/test/bls_tests.cpp +++ b/src/test/bls_tests.cpp @@ -70,7 +70,7 @@ struct Member CBLSSecretKey sk; CBLSPublicKey pk; - Member(const CBLSId& _id): id(_id) + explicit Member(const CBLSId& _id): id(_id) { sk.MakeNewKey(); pk = sk.GetPublicKey(); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index af80ca4adc187..6240821ac5e29 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -191,7 +191,7 @@ class TxWithNullifiers class CCoinsViewCacheTest : public CCoinsViewCache { public: - CCoinsViewCacheTest(CCoinsView* base) : CCoinsViewCache(base) {} + explicit CCoinsViewCacheTest(CCoinsView* base) : CCoinsViewCache(base) {} void SelfTest() const { diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index daa484c729aae..79c68027290bd 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -232,7 +232,7 @@ struct StringContentsSerializer { // 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/librust/sapling_rpc_wallet_tests.cpp b/src/test/librust/sapling_rpc_wallet_tests.cpp index 277fa5c2c1bc7..d4647b4eaa1dd 100644 --- a/src/test/librust/sapling_rpc_wallet_tests.cpp +++ b/src/test/librust/sapling_rpc_wallet_tests.cpp @@ -34,7 +34,7 @@ namespace { /** Set the working directory for the duration of the scope. */ class PushCurrentDirectory { public: - PushCurrentDirectory(const std::string &new_cwd) + explicit PushCurrentDirectory(const std::string &new_cwd) : old_cwd(fs::current_path()) { fs::current_path(new_cwd); } diff --git a/src/test/librust/sapling_test_fixture.h b/src/test/librust/sapling_test_fixture.h index 10d3f601b03ec..3440e54d7beaf 100644 --- a/src/test/librust/sapling_test_fixture.h +++ b/src/test/librust/sapling_test_fixture.h @@ -12,7 +12,7 @@ */ struct SaplingTestingSetup : public TestingSetup { - SaplingTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); + explicit SaplingTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); ~SaplingTestingSetup(); }; diff --git a/src/test/test_pivx.h b/src/test/test_pivx.h index e326a8126e6f2..701242cb9fece 100644 --- a/src/test/test_pivx.h +++ b/src/test/test_pivx.h @@ -51,7 +51,7 @@ static inline std::vector InsecureRandBytes(size_t len) { return struct BasicTestingSetup { ECCVerifyHandle globalVerifyHandle; - BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); + explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); ~BasicTestingSetup(); fs::path SetDataDir(const std::string& name); @@ -75,7 +75,7 @@ struct TestingSetup: public BasicTestingSetup CScheduler scheduler; std::unique_ptr peerLogic; - TestingSetup(const std::string& chainName = CBaseChainParams::MAIN); + explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN); ~TestingSetup(); }; @@ -99,7 +99,7 @@ class CScript; // Test chain only available on regtest struct TestChainSetup : public TestingSetup { - TestChainSetup(int blockCount); + explicit TestChainSetup(int blockCount); ~TestChainSetup(); // Create a new block with coinbase paying to scriptPubKey, and try to add it to the current chain. diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp index 6a5a02fed10c9..e75147bfbbb43 100644 --- a/src/test/validation_block_tests.cpp +++ b/src/test/validation_block_tests.cpp @@ -24,7 +24,7 @@ BOOST_FIXTURE_TEST_SUITE(validation_block_tests, RegTestingSetup) struct TestSubscriber : public CValidationInterface { uint256 m_expected_tip; - TestSubscriber(uint256 tip) : m_expected_tip(std::move(tip)) {} + explicit TestSubscriber(uint256 tip) : m_expected_tip(std::move(tip)) {} void UpdatedBlockTip(const CBlockIndex* pindexNew, const CBlockIndex* pindexFork, bool fInitialDownload) { diff --git a/src/tiertwo/netfulfilledman.h b/src/tiertwo/netfulfilledman.h index be345c49bcee9..01534145f2c17 100644 --- a/src/tiertwo/netfulfilledman.h +++ b/src/tiertwo/netfulfilledman.h @@ -40,7 +40,7 @@ class CNetFulfilledRequestManager int64_t lastFilterCleanup{0}; public: - CNetFulfilledRequestManager(unsigned int itemsFilterSize); + explicit CNetFulfilledRequestManager(unsigned int itemsFilterSize); SERIALIZE_METHODS(CNetFulfilledRequestManager, obj) { LOCK(obj.cs_mapFulfilledRequests); diff --git a/src/tinyformat.h b/src/tinyformat.h index 7948caf9be66e..f3b1bad434dca 100644 --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -170,7 +170,7 @@ namespace tinyformat class format_error: public std::runtime_error { public: - format_error(const std::string &what): std::runtime_error(what) { + explicit format_error(const std::string &what): std::runtime_error(what) { } }; @@ -512,7 +512,7 @@ class FormatArg FormatArg() {} template - FormatArg(const T& value) + explicit FormatArg(const T& value) : m_value(static_cast(&value)), m_formatImpl(&formatImpl), m_toIntImpl(&toIntImpl) @@ -871,7 +871,7 @@ class FormatListN : public FormatList 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"); } @@ -880,7 +880,7 @@ class FormatListN : public FormatList # define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \ \ template \ - FormatListN(TINYFORMAT_VARARGS(n)) \ + explicit FormatListN(TINYFORMAT_VARARGS(n)) \ : FormatList(&m_formatterStore[0], n) \ { assert(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \ \ diff --git a/src/txdb.h b/src/txdb.h index b6703340c395b..03ed9b1c60370 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -73,7 +73,7 @@ class CCoinsViewDB : public CCoinsView 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; @@ -127,7 +127,7 @@ class CCoinsViewDBCursor: public CCoinsViewCursor 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); CBlockTreeDB(const CBlockTreeDB&) = delete; CBlockTreeDB& operator=(const CBlockTreeDB&) = delete; @@ -151,7 +151,7 @@ class CBlockTreeDB : public CDBWrapper class CZerocoinDB : public CDBWrapper { public: - CZerocoinDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); + explicit CZerocoinDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); private: CZerocoinDB(const CZerocoinDB&); diff --git a/src/txmempool.h b/src/txmempool.h index 8982ea3aed1fd..ecd52b9f5cd53 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -153,7 +153,7 @@ struct update_ancestor_state struct update_fee_delta { - update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { } + explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { } void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); } @@ -514,7 +514,7 @@ class CTxMemPool * around what it "costs" to relay a transaction around the network and * below which we would reasonably say a transaction has 0-effective-fee. */ - CTxMemPool(const CFeeRate& _minReasonableRelayFee); + explicit CTxMemPool(const CFeeRate& _minReasonableRelayFee); ~CTxMemPool(); /** diff --git a/src/uint256.h b/src/uint256.h index 1bcce65acdf6c..5a01192128f19 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -116,7 +116,7 @@ class base_blob class blob88 : public base_blob<88> { public: blob88() {} - blob88(const base_blob<88>& b) : base_blob<88>(b) {} + explicit blob88(const base_blob<88>& b) : base_blob<88>(b) {} explicit blob88(const std::vector& vch) : base_blob<88>(vch) {} }; @@ -184,7 +184,7 @@ const uint256 UINT256_MAX = uint256S("ffffffffffffffffffffffffffffffffffffffffff class uint512 : public base_blob<512> { public: uint512() {} - uint512(const base_blob<512>& b) : base_blob<512>(b) {} + explicit uint512(const base_blob<512>& b) : base_blob<512>(b) {} explicit uint512(const std::vector& vch) : base_blob<512>(vch) {} }; diff --git a/src/util/blockstatecatcher.h b/src/util/blockstatecatcher.h index a03dac22d0f8d..93e36e014f630 100644 --- a/src/util/blockstatecatcher.h +++ b/src/util/blockstatecatcher.h @@ -17,7 +17,7 @@ class BlockStateCatcher : public CValidationInterface uint256 hash; bool found; CValidationState state; - BlockStateCatcher(const uint256& hashIn) : hash(hashIn), found(false), state(){}; + explicit BlockStateCatcher(const uint256& hashIn) : hash(hashIn), found(false), state(){}; void setBlockHash(const uint256& _hash) { clear(); hash = _hash; } void clear() { hash.SetNull(); found = false; state = CValidationState(); } bool stateErrorFound() { return found && state.IsError(); } diff --git a/src/wallet/db.h b/src/wallet/db.h index da991d13a9fb3..733479411e07c 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -46,7 +46,7 @@ class BerkeleyEnvironment std::unordered_map m_fileids; std::condition_variable_any m_db_in_use; - BerkeleyEnvironment(const fs::path& env_directory); + explicit BerkeleyEnvironment(const fs::path& env_directory); ~BerkeleyEnvironment(); void Reset(); @@ -111,7 +111,7 @@ class BerkeleyDatabase } /** Create DB handle to real database */ - BerkeleyDatabase(const fs::path& wallet_path, bool mock = false) : + explicit BerkeleyDatabase(const fs::path& wallet_path, bool mock = false) : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0) { env = GetWalletEnv(wallet_path, strFile); diff --git a/src/wallet/hdchain.h b/src/wallet/hdchain.h index 3cf1c95006e27..04c42144aa867 100644 --- a/src/wallet/hdchain.h +++ b/src/wallet/hdchain.h @@ -37,7 +37,7 @@ class CHDChain // Chain counter type uint8_t chainType{HDChain::ChainCounterType::Standard}; - CHDChain(const uint8_t& _chainType = HDChain::ChainCounterType::Standard) : chainType(_chainType) { SetNull(); } + explicit CHDChain(const uint8_t& _chainType = HDChain::ChainCounterType::Standard) : chainType(_chainType) { SetNull(); } SERIALIZE_METHODS(CHDChain, obj) { diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 21e89d1a79444..0fdae258eb427 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -24,7 +24,7 @@ static const uint32_t BIP32_HARDENED_KEY_LIMIT = 0x80000000; class ScriptPubKeyMan { public: - ScriptPubKeyMan(CWallet* parent) : wallet(parent) {} + explicit ScriptPubKeyMan(CWallet* parent) : wallet(parent) {} ~ScriptPubKeyMan() {}; /* Set the HD chain model (chain child index counters) */ diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index 19bc1ebc5a477..6c9326e9447b2 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -23,7 +23,7 @@ struct WalletTestingSetupBase : public SaplingTestingSetup struct WalletTestingSetup : public WalletTestingSetupBase { - WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); + explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); }; struct WalletRegTestingSetup : public WalletTestingSetup diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 6b8258cc13fc3..1ceadf74fa882 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1261,7 +1261,7 @@ class CReserveKey CPubKey vchPubKey; public: - CReserveKey(CWallet* pwalletIn) + explicit CReserveKey(CWallet* pwalletIn) { nIndex = -1; pwallet = pwalletIn; diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 434641875ee72..d3167c6cd9edb 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -74,7 +74,8 @@ class CKeyMetadata { SetNull(); } - CKeyMetadata(int64_t nCreateTime_) + + explicit CKeyMetadata(int64_t nCreateTime_) { SetNull(); nCreateTime = nCreateTime_; diff --git a/src/zpiv/zpivmodule.h b/src/zpiv/zpivmodule.h index 82513b5bd582a..0fd412077bd9c 100644 --- a/src/zpiv/zpivmodule.h +++ b/src/zpiv/zpivmodule.h @@ -24,7 +24,7 @@ static int const PUBSPEND_SCHNORR = 4; class PublicCoinSpend : public libzerocoin::CoinSpend { public: - PublicCoinSpend(libzerocoin::ZerocoinParams* params): pubCoin(params) {}; + explicit PublicCoinSpend(libzerocoin::ZerocoinParams* params): pubCoin(params) {}; template PublicCoinSpend(libzerocoin::ZerocoinParams* params, Stream& strm); ~PublicCoinSpend(){};