Skip to content

Commit

Permalink
Declare single-argument (non-converting) constructors "explicit"
Browse files Browse the repository at this point in the history
  • Loading branch information
Fuzzbawls committed Nov 13, 2024
1 parent a34f0d3 commit 43b75ca
Show file tree
Hide file tree
Showing 88 changed files with 121 additions and 121 deletions.
2 changes: 1 addition & 1 deletion src/addrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CBanEntry
SetNull();
}

CBanEntry(int64_t nCreateTimeIn)
explicit CBanEntry(int64_t nCreateTimeIn)
{
SetNull();
nCreateTime = nCreateTimeIn;
Expand Down
4 changes: 2 additions & 2 deletions src/blockassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -117,7 +117,7 @@ typedef indexed_modified_transaction_set::index<ancestor_score>::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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/bls/bls_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class CBLSWorkerCache
std::map<uint256, std::shared_future<CBLSPublicKey> > publicKeyShareCache;

public:
CBLSWorkerCache(CBLSWorker& _worker) :
explicit CBLSWorkerCache(CBLSWorker& _worker) :
worker(_worker) {}

BLSVerificationVectorPtr BuildQuorumVerificationVector(const uint256& cacheKey, const std::vector<BLSVerificationVectorPtr>& vvecs)
Expand Down
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class CBlockIndex
unsigned int nTimeMax{0};

CBlockIndex() {}
CBlockIndex(const CBlock& block);
explicit CBlockIndex(const CBlock& block);

std::string ToString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, uint256> MapCheckpoints;
Expand Down
2 changes: 1 addition & 1 deletion src/checkqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class CCheckQueueControl
bool fDone;

public:
CCheckQueueControl(CCheckQueue<T>* pqueueIn) : pqueue(pqueueIn), fDone(false)
explicit CCheckQueueControl(CCheckQueue<T>* pqueueIn) : pqueue(pqueueIn), fDone(false)
{
// passed queue is supposed to be unused, or nullptr
if (pqueue != nullptr) {
Expand Down
8 changes: 4 additions & 4 deletions src/crypto/aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion src/ctpl_stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/cxxtimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/dbwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint64_t>::max());
Expand Down
2 changes: 1 addition & 1 deletion src/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/httprpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/httpserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class HTTPRequest
bool replySent;

public:
HTTPRequest(struct evhttp_request* req);
explicit HTTPRequest(struct evhttp_request* req);
~HTTPRequest();

enum RequestMethod {
Expand Down
2 changes: 1 addition & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/key_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/libzerocoin/Coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -54,7 +54,7 @@ class PublicCoin
strm >> *this;
}

PublicCoin(const ZerocoinParams* p);
explicit PublicCoin(const ZerocoinParams* p);

/**Generates a public coin
*
Expand Down
2 changes: 1 addition & 1 deletion src/libzerocoin/CoinRandomnessSchnorrSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace libzerocoin {
class CoinRandomnessSchnorrSignature {
public:
CoinRandomnessSchnorrSignature() {};
template <typename Stream> CoinRandomnessSchnorrSignature(Stream& strm) {strm >> *this;}
template <typename Stream> explicit CoinRandomnessSchnorrSignature(Stream& strm) {strm >> *this;}

/** Creates a Schnorr signature object using the randomness of a public coin as private key sk.
*
Expand Down
2 changes: 1 addition & 1 deletion src/libzerocoin/CoinSpend.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 1 addition & 2 deletions src/libzerocoin/Params.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/limitedmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_chainlocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/llmq/quorums_dkgsession.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CDKGComplaint

public:
CDKGComplaint() {}
CDKGComplaint(const Consensus::LLMQParams& params);
explicit CDKGComplaint(const Consensus::LLMQParams& params);

SERIALIZE_METHODS(CDKGComplaint, obj)
{
Expand Down Expand Up @@ -163,7 +163,7 @@ class CDKGPrematureCommitment

public:
CDKGPrematureCommitment() {}
CDKGPrematureCommitment(const Consensus::LLMQParams& params);
explicit CDKGPrematureCommitment(const Consensus::LLMQParams& params);

int CountValidMembers() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_dkgsessionhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class CDKGPendingMessages
std::set<uint256> seenMessages;

public:
CDKGPendingMessages(size_t _maxMessagesPerNode);
explicit CDKGPendingMessages(size_t _maxMessagesPerNode);

void PushPendingMessage(NodeId from, CDataStream& vRecv, int invType);
std::list<BinaryMessage> PopPendingMessages(size_t maxCount);
Expand Down
2 changes: 1 addition & 1 deletion src/llmq/quorums_signing.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CRecoveredSigsDb
unordered_lru_cache<uint256, bool, StaticSaltedHasher, 30000> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class CMasternodeBlockPayees
nBlockHeight = 0;
vecPayments.clear();
}
CMasternodeBlockPayees(int nBlockHeightIn)
explicit CMasternodeBlockPayees(int nBlockHeightIn)
{
nBlockHeight = nBlockHeightIn;
vecPayments.clear();
Expand Down
2 changes: 1 addition & 1 deletion src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ class CompareInvMempoolOrder
{
CTxMemPool *mp;
public:
CompareInvMempoolOrder(CTxMemPool *_mempool)
explicit CompareInvMempoolOrder(CTxMemPool *_mempool)
{
mp = _mempool;
}
Expand Down
2 changes: 1 addition & 1 deletion src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<const CBlock>& pblock, const CBlockIndex* pindex) override;
Expand Down
6 changes: 3 additions & 3 deletions src/netaddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class CNetAddr
std::vector<unsigned char> 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);
Expand Down Expand Up @@ -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);
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/netbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }

Expand Down
2 changes: 1 addition & 1 deletion src/netmessagemaker.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CNetMsgMaker
{
public:
CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}
explicit CNetMsgMaker(int nVersionIn) : nVersion(nVersionIn){}

template <typename... Args>
CSerializedNetMsg Make(int nFlags, std::string sCommand, Args&&... args)
Expand Down
4 changes: 2 additions & 2 deletions src/operationresult.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class CallResult : public OperationResult
Optional<T> 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<T>& getObjResult() const { return m_obj_res; }
};

Expand Down
2 changes: 1 addition & 1 deletion src/policy/fees.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct CBlockLocator

CBlockLocator() {}

CBlockLocator(const std::vector<uint256>& vHaveIn)
explicit CBlockLocator(const std::vector<uint256>& vHaveIn)
{
vHave = vHaveIn;
}
Expand Down
2 changes: 1 addition & 1 deletion src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 43b75ca

Please sign in to comment.