Browse Source

Declare single-argument (non-converting) constructors "explicit"

In order to avoid unintended implicit conversions.
0.16
practicalswift 7 years ago
parent
commit
64fb0ac016
  1. 2
      src/addrdb.h
  2. 2
      src/base58.cpp
  3. 2
      src/bench/checkqueue.cpp
  4. 6
      src/blockencodings.h
  5. 2
      src/chain.h
  6. 2
      src/checkqueue.h
  7. 4
      src/compressor.h
  8. 8
      src/crypto/aes.h
  9. 2
      src/cuckoocache.h
  10. 4
      src/dbwrapper.h
  11. 2
      src/hash.h
  12. 2
      src/httprpc.cpp
  13. 4
      src/httpserver.cpp
  14. 2
      src/httpserver.h
  15. 2
      src/init.cpp
  16. 2
      src/limitedmap.h
  17. 6
      src/miner.h
  18. 2
      src/net_processing.cpp
  19. 2
      src/net_processing.h
  20. 8
      src/netaddress.h
  21. 2
      src/netbase.h
  22. 2
      src/netmessagemaker.h
  23. 2
      src/policy/fees.h
  24. 2
      src/primitives/block.h
  25. 2
      src/protocol.h
  26. 4
      src/pubkey.h
  27. 2
      src/qt/callback.h
  28. 6
      src/qt/coincontroldialog.h
  29. 2
      src/qt/intro.cpp
  30. 2
      src/qt/notificator.cpp
  31. 2
      src/qt/overviewpage.cpp
  32. 2
      src/qt/paymentrequestplus.cpp
  33. 2
      src/qt/paymentserver.h
  34. 2
      src/qt/utilitydialog.h
  35. 2
      src/rest.cpp
  36. 2
      src/reverse_iterator.h
  37. 2
      src/rpc/mining.cpp
  38. 2
      src/rpc/misc.cpp
  39. 2
      src/rpc/server.h
  40. 2
      src/scheduler.cpp
  41. 2
      src/scheduler.h
  42. 2
      src/script/interpreter.h
  43. 4
      src/script/sign.h
  44. 2
      src/script/standard.cpp
  45. 6
      src/serialize.h
  46. 4
      src/support/lockedpool.h
  47. 4
      src/sync.h
  48. 4
      src/test/base58_tests.cpp
  49. 2
      src/test/bip32_tests.cpp
  50. 4
      src/test/blockencodings_tests.cpp
  51. 2
      src/test/coins_tests.cpp
  52. 2
      src/test/dbwrapper_tests.cpp
  53. 4
      src/test/test_bitcoin.h
  54. 8
      src/tinyformat.h
  55. 2
      src/torcontrol.cpp
  56. 2
      src/txdb.cpp
  57. 4
      src/txdb.h
  58. 6
      src/txmempool.h
  59. 4
      src/uint256.h
  60. 4
      src/undo.h
  61. 2
      src/univalue/lib/univalue_utffilter.h
  62. 4
      src/validation.cpp
  63. 2
      src/validationinterface.cpp
  64. 2
      src/versionbits.cpp
  65. 2
      src/wallet/rpcwallet.cpp
  66. 2
      src/wallet/test/wallet_test_fixture.h
  67. 8
      src/wallet/wallet.h
  68. 4
      src/wallet/walletdb.h

2
src/addrdb.h

@ -37,7 +37,7 @@ public: @@ -37,7 +37,7 @@ public:
SetNull();
}
CBanEntry(int64_t nCreateTimeIn)
explicit CBanEntry(int64_t nCreateTimeIn)
{
SetNull();
nCreateTime = nCreateTimeIn;

2
src/base58.cpp

@ -218,7 +218,7 @@ private: @@ -218,7 +218,7 @@ private:
CBitcoinAddress* addr;
public:
CBitcoinAddressVisitor(CBitcoinAddress* addrIn) : addr(addrIn) {}
explicit CBitcoinAddressVisitor(CBitcoinAddress* addrIn) : addr(addrIn) {}
bool operator()(const CKeyID& id) const { return addr->Set(id); }
bool operator()(const CScriptID& id) const { return addr->Set(id); }

2
src/bench/checkqueue.cpp

@ -67,7 +67,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state) @@ -67,7 +67,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::State& state)
prevector<PREVECTOR_SIZE, uint8_t> p;
PrevectorJob(){
}
PrevectorJob(FastRandomContext& insecure_rand){
explicit PrevectorJob(FastRandomContext& insecure_rand){
p.resize(insecure_rand.randrange(PREVECTOR_SIZE*2));
}
bool operator()()

6
src/blockencodings.h

@ -16,7 +16,7 @@ struct TransactionCompressor { @@ -16,7 +16,7 @@ struct TransactionCompressor {
private:
CTransactionRef& tx;
public:
TransactionCompressor(CTransactionRef& txIn) : tx(txIn) {}
explicit TransactionCompressor(CTransactionRef& txIn) : tx(txIn) {}
ADD_SERIALIZE_METHODS;
@ -75,7 +75,7 @@ public: @@ -75,7 +75,7 @@ public:
std::vector<CTransactionRef> txn;
BlockTransactions() {}
BlockTransactions(const BlockTransactionsRequest& req) :
explicit BlockTransactions(const BlockTransactionsRequest& req) :
blockhash(req.blockhash), txn(req.indexes.size()) {}
ADD_SERIALIZE_METHODS;
@ -198,7 +198,7 @@ protected: @@ -198,7 +198,7 @@ protected:
CTxMemPool* pool;
public:
CBlockHeader header;
PartiallyDownloadedBlock(CTxMemPool* poolIn) : pool(poolIn) {}
explicit PartiallyDownloadedBlock(CTxMemPool* poolIn) : pool(poolIn) {}
// extra_txn is a list of extra transactions to look at, in <witness hash, reference> form
ReadStatus InitData(const CBlockHeaderAndShortTxIDs& cmpctblock, const std::vector<std::pair<uint256, CTransactionRef>>& extra_txn);

2
src/chain.h

@ -247,7 +247,7 @@ public: @@ -247,7 +247,7 @@ public:
SetNull();
}
CBlockIndex(const CBlockHeader& block)
explicit CBlockIndex(const CBlockHeader& block)
{
SetNull();

2
src/checkqueue.h

@ -131,7 +131,7 @@ public: @@ -131,7 +131,7 @@ public:
boost::mutex ControlMutex;
//! Create a new check queue
CCheckQueue(unsigned int nBatchSizeIn) : nIdle(0), nTotal(0), fAllOk(true), nTodo(0), fQuit(false), nBatchSize(nBatchSizeIn) {}
explicit CCheckQueue(unsigned int nBatchSizeIn) : nIdle(0), nTotal(0), fAllOk(true), nTodo(0), fQuit(false), nBatchSize(nBatchSizeIn) {}
//! Worker thread
void Thread()

4
src/compressor.h

@ -53,7 +53,7 @@ protected: @@ -53,7 +53,7 @@ protected:
unsigned int GetSpecialSize(unsigned int nSize) const;
bool Decompress(unsigned int nSize, const std::vector<unsigned char> &out);
public:
CScriptCompressor(CScript &scriptIn) : script(scriptIn) { }
explicit CScriptCompressor(CScript &scriptIn) : script(scriptIn) { }
template<typename Stream>
void Serialize(Stream &s) const {
@ -99,7 +99,7 @@ public: @@ -99,7 +99,7 @@ public:
static uint64_t CompressAmount(uint64_t nAmount);
static uint64_t DecompressAmount(uint64_t nAmount);
CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { }
explicit CTxOutCompressor(CTxOut &txoutIn) : txout(txoutIn) { }
ADD_SERIALIZE_METHODS;

8
src/crypto/aes.h

@ -22,7 +22,7 @@ private: @@ -22,7 +22,7 @@ private:
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 @@ private: @@ -34,7 +34,7 @@ private:
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 @@ private: @@ -46,7 +46,7 @@ private:
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 @@ private: @@ -58,7 +58,7 @@ private:
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;
};

2
src/cuckoocache.h

@ -58,7 +58,7 @@ public: @@ -58,7 +58,7 @@ public:
* @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;

4
src/dbwrapper.h

@ -22,7 +22,7 @@ static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024; @@ -22,7 +22,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;
@ -61,7 +61,7 @@ public: @@ -61,7 +61,7 @@ public:
/**
* @param[in] _parent CDBWrapper that this batch is to be submitted to
*/
CDBBatch(const CDBWrapper &_parent) : parent(_parent), ssKey(SER_DISK, CLIENT_VERSION), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0) { };
explicit CDBBatch(const CDBWrapper &_parent) : parent(_parent), ssKey(SER_DISK, CLIENT_VERSION), ssValue(SER_DISK, CLIENT_VERSION), size_estimate(0) { };
void Clear()
{

2
src/hash.h

@ -168,7 +168,7 @@ private: @@ -168,7 +168,7 @@ private:
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)
{

2
src/httprpc.cpp

@ -43,7 +43,7 @@ private: @@ -43,7 +43,7 @@ private:
class HTTPRPCTimerInterface : public RPCTimerInterface
{
public:
HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
explicit HTTPRPCTimerInterface(struct event_base* _base) : base(_base)
{
}
const char* Name() override

4
src/httpserver.cpp

@ -79,7 +79,7 @@ private: @@ -79,7 +79,7 @@ private:
{
public:
WorkQueue &wq;
ThreadCounter(WorkQueue &w): wq(w)
explicit ThreadCounter(WorkQueue &w): wq(w)
{
std::lock_guard<std::mutex> lock(wq.cs);
wq.numThreads += 1;
@ -93,7 +93,7 @@ private: @@ -93,7 +93,7 @@ private:
};
public:
WorkQueue(size_t _maxDepth) : running(true),
explicit WorkQueue(size_t _maxDepth) : running(true),
maxDepth(_maxDepth),
numThreads(0)
{

2
src/httpserver.h

@ -61,7 +61,7 @@ private: @@ -61,7 +61,7 @@ private:
bool replySent;
public:
HTTPRequest(struct evhttp_request* req);
explicit HTTPRequest(struct evhttp_request* req);
~HTTPRequest();
enum RequestMethod {

2
src/init.cpp

@ -136,7 +136,7 @@ bool ShutdownRequested() @@ -136,7 +136,7 @@ bool ShutdownRequested()
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 {
return CCoinsViewBacked::GetCoin(outpoint, coin);

2
src/limitedmap.h

@ -27,7 +27,7 @@ protected: @@ -27,7 +27,7 @@ protected:
size_type nMaxSize;
public:
limitedmap(size_type nMaxSizeIn)
explicit limitedmap(size_type nMaxSizeIn)
{
assert(nMaxSizeIn > 0);
nMaxSize = nMaxSizeIn;

6
src/miner.h

@ -33,7 +33,7 @@ struct CBlockTemplate @@ -33,7 +33,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();
@ -116,7 +116,7 @@ typedef indexed_modified_transaction_set::index<ancestor_score>::type::iterator @@ -116,7 +116,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)
{
@ -164,7 +164,7 @@ public: @@ -164,7 +164,7 @@ public:
CFeeRate blockMinFeeRate;
};
BlockAssembler(const CChainParams& params);
explicit BlockAssembler(const CChainParams& params);
BlockAssembler(const CChainParams& params, const Options& options);
/** Construct a new block template with coinbase to scriptPubKeyIn */

2
src/net_processing.cpp

@ -2783,7 +2783,7 @@ class CompareInvMempoolOrder @@ -2783,7 +2783,7 @@ class CompareInvMempoolOrder
{
CTxMemPool *mp;
public:
CompareInvMempoolOrder(CTxMemPool *_mempool)
explicit CompareInvMempoolOrder(CTxMemPool *_mempool)
{
mp = _mempool;
}

2
src/net_processing.h

@ -32,7 +32,7 @@ private: @@ -32,7 +32,7 @@ private:
CConnman* connman;
public:
PeerLogicValidation(CConnman* connmanIn);
explicit PeerLogicValidation(CConnman* connmanIn);
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;

8
src/netaddress.h

@ -36,7 +36,7 @@ class CNetAddr @@ -36,7 +36,7 @@ class CNetAddr
public:
CNetAddr();
CNetAddr(const struct in_addr& ipv4Addr);
explicit CNetAddr(const struct in_addr& ipv4Addr);
void Init();
void SetIP(const CNetAddr& ip);
@ -82,7 +82,7 @@ class CNetAddr @@ -82,7 +82,7 @@ class CNetAddr
std::vector<unsigned char> 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);
@ -146,7 +146,7 @@ class CService : public CNetAddr @@ -146,7 +146,7 @@ class CService : public CNetAddr
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);
void Init();
unsigned short GetPort() const;
bool GetSockAddr(struct sockaddr* paddr, socklen_t *addrlen) const;
@ -160,7 +160,7 @@ class CService : public CNetAddr @@ -160,7 +160,7 @@ class CService : public CNetAddr
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;

2
src/netbase.h

@ -29,7 +29,7 @@ class proxyType @@ -29,7 +29,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(); }

2
src/netmessagemaker.h

@ -12,7 +12,7 @@ @@ -12,7 +12,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) const

2
src/policy/fees.h

@ -284,7 +284,7 @@ private: @@ -284,7 +284,7 @@ private:
public:
/** Create new FeeFilterRounder */
FeeFilterRounder(const CFeeRate& minIncrementalFee);
explicit FeeFilterRounder(const CFeeRate& minIncrementalFee);
/** Quantize a minimum fee for privacy purpose before broadcast **/
CAmount round(CAmount currentMinFee);

2
src/primitives/block.h

@ -129,7 +129,7 @@ struct CBlockLocator @@ -129,7 +129,7 @@ struct CBlockLocator
CBlockLocator() {}
CBlockLocator(const std::vector<uint256>& vHaveIn) : vHave(vHaveIn) {}
explicit CBlockLocator(const std::vector<uint256>& vHaveIn) : vHave(vHaveIn) {}
ADD_SERIALIZE_METHODS;

2
src/protocol.h

@ -39,7 +39,7 @@ public: @@ -39,7 +39,7 @@ public:
};
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
CMessageHeader(const MessageStartChars& pchMessageStartIn);
explicit CMessageHeader(const MessageStartChars& pchMessageStartIn);
CMessageHeader(const MessageStartChars& pchMessageStartIn, const char* pszCommand, unsigned int nMessageSizeIn);
std::string GetCommand() const;

4
src/pubkey.h

@ -30,7 +30,7 @@ class CKeyID : public uint160 @@ -30,7 +30,7 @@ class CKeyID : public uint160
{
public:
CKeyID() : uint160() {}
CKeyID(const uint160& in) : uint160(in) {}
explicit CKeyID(const uint160& in) : uint160(in) {}
};
typedef uint256 ChainCode;
@ -88,7 +88,7 @@ public: @@ -88,7 +88,7 @@ public:
}
//! Construct a public key from a byte vector.
CPubKey(const std::vector<unsigned char>& _vch)
explicit CPubKey(const std::vector<unsigned char>& _vch)
{
Set(_vch.begin(), _vch.end());
}

2
src/qt/callback.h

@ -16,7 +16,7 @@ class FunctionCallback : public Callback @@ -16,7 +16,7 @@ class FunctionCallback : public Callback
F f;
public:
FunctionCallback(F f_) : f(std::move(f_)) {}
explicit FunctionCallback(F f_) : f(std::move(f_)) {}
~FunctionCallback() override {}
void call() override { f(this); }
};

6
src/qt/coincontroldialog.h

@ -30,9 +30,9 @@ namespace Ui { @@ -30,9 +30,9 @@ namespace Ui {
class CCoinControlWidgetItem : public QTreeWidgetItem
{
public:
CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {}
CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
explicit CCoinControlWidgetItem(QTreeWidget *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
explicit CCoinControlWidgetItem(int type = Type) : QTreeWidgetItem(type) {}
explicit CCoinControlWidgetItem(QTreeWidgetItem *parent, int type = Type) : QTreeWidgetItem(parent, type) {}
bool operator<(const QTreeWidgetItem &other) const;
};

2
src/qt/intro.cpp

@ -43,7 +43,7 @@ class FreespaceChecker : public QObject @@ -43,7 +43,7 @@ class FreespaceChecker : public QObject
Q_OBJECT
public:
FreespaceChecker(Intro *intro);
explicit FreespaceChecker(Intro *intro);
enum Status {
ST_OK,

2
src/qt/notificator.cpp

@ -93,7 +93,7 @@ class FreedesktopImage @@ -93,7 +93,7 @@ class FreedesktopImage
{
public:
FreedesktopImage() {}
FreedesktopImage(const QImage &img);
explicit FreedesktopImage(const QImage &img);
static int metaType();

2
src/qt/overviewpage.cpp

@ -25,7 +25,7 @@ class TxViewDelegate : public QAbstractItemDelegate @@ -25,7 +25,7 @@ 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::BTC),
platformStyle(_platformStyle)
{

2
src/qt/paymentrequestplus.cpp

@ -22,7 +22,7 @@ @@ -22,7 +22,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)

2
src/qt/paymentserver.h

@ -72,7 +72,7 @@ public: @@ -72,7 +72,7 @@ public:
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)

2
src/qt/utilitydialog.h

@ -41,7 +41,7 @@ class ShutdownWindow : public QWidget @@ -41,7 +41,7 @@ class ShutdownWindow : public QWidget
Q_OBJECT
public:
ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
explicit ShutdownWindow(QWidget *parent=0, Qt::WindowFlags f=0);
static QWidget *showShutdownWindow(BitcoinGUI *window);
protected:

2
src/rest.cpp

@ -48,7 +48,7 @@ struct CCoin { @@ -48,7 +48,7 @@ struct CCoin {
ADD_SERIALIZE_METHODS;
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)) {}
template <typename Stream, typename Operation>
inline void SerializationOp(Stream& s, Operation ser_action)

2
src/reverse_iterator.h

@ -17,7 +17,7 @@ class reverse_range @@ -17,7 +17,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())
{

2
src/rpc/mining.cpp

@ -686,7 +686,7 @@ public: @@ -686,7 +686,7 @@ public:
bool found;
CValidationState state;
submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {}
explicit submitblock_StateCatcher(const uint256 &hashIn) : hash(hashIn), found(false), state() {}
protected:
void BlockChecked(const CBlock& block, const CValidationState& stateIn) override {

2
src/rpc/misc.cpp

@ -125,7 +125,7 @@ class DescribeAddressVisitor : public boost::static_visitor<UniValue> @@ -125,7 +125,7 @@ class DescribeAddressVisitor : public boost::static_visitor<UniValue>
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); }

2
src/rpc/server.h

@ -31,7 +31,7 @@ namespace RPCServer @@ -31,7 +31,7 @@ namespace RPCServer
/** Wrapper for UniValue::VType, which includes typeAny:
* Used to denote don't 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;

2
src/scheduler.cpp

@ -174,7 +174,7 @@ void SingleThreadedSchedulerClient::ProcessQueue() { @@ -174,7 +174,7 @@ void SingleThreadedSchedulerClient::ProcessQueue() {
// to ensure both happen safely even if callback() throws.
struct RAIICallbacksRunning {
SingleThreadedSchedulerClient* instance;
RAIICallbacksRunning(SingleThreadedSchedulerClient* _instance) : instance(_instance) {}
explicit RAIICallbacksRunning(SingleThreadedSchedulerClient* _instance) : instance(_instance) {}
~RAIICallbacksRunning() {
{
LOCK(instance->m_cs_callbacks_pending);

2
src/scheduler.h

@ -102,7 +102,7 @@ private: @@ -102,7 +102,7 @@ private:
void ProcessQueue();
public:
SingleThreadedSchedulerClient(CScheduler *pschedulerIn) : m_pscheduler(pschedulerIn) {}
explicit SingleThreadedSchedulerClient(CScheduler *pschedulerIn) : m_pscheduler(pschedulerIn) {}
void AddToProcessQueue(std::function<void (void)> func);
// Processes all remaining queue members on the calling thread, blocking until queue is empty

2
src/script/interpreter.h

@ -114,7 +114,7 @@ struct PrecomputedTransactionData @@ -114,7 +114,7 @@ struct PrecomputedTransactionData
{
uint256 hashPrevouts, hashSequence, hashOutputs;
PrecomputedTransactionData(const CTransaction& tx);
explicit PrecomputedTransactionData(const CTransaction& tx);
};
enum SigVersion

4
src/script/sign.h

@ -21,7 +21,7 @@ protected: @@ -21,7 +21,7 @@ protected:
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;
@ -54,7 +54,7 @@ public: @@ -54,7 +54,7 @@ public:
/** A signature creator that just produces 72-byte empty signatures. */
class DummySignatureCreator : public BaseSignatureCreator {
public:
DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
explicit DummySignatureCreator(const CKeyStore* keystoreIn) : BaseSignatureCreator(keystoreIn) {}
const BaseSignatureChecker& Checker() const override;
bool CreateSig(std::vector<unsigned char>& vchSig, const CKeyID& keyid, const CScript& scriptCode, SigVersion sigversion) const override;
};

2
src/script/standard.cpp

@ -253,7 +253,7 @@ class CScriptVisitor : public boost::static_visitor<bool> @@ -253,7 +253,7 @@ class CScriptVisitor : public boost::static_visitor<bool>
private:
CScript *script;
public:
CScriptVisitor(CScript *scriptin) { script = scriptin; }
explicit CScriptVisitor(CScript *scriptin) { script = scriptin; }
bool operator()(const CNoDestination &dest) const {
script->clear();

6
src/serialize.h

@ -402,7 +402,7 @@ class CVarInt @@ -402,7 +402,7 @@ class CVarInt
protected:
I &n;
public:
CVarInt(I& nIn) : n(nIn) { }
explicit CVarInt(I& nIn) : n(nIn) { }
template<typename Stream>
void Serialize(Stream &s) const {
@ -420,7 +420,7 @@ class CCompactSize @@ -420,7 +420,7 @@ class CCompactSize
protected:
uint64_t &n;
public:
CCompactSize(uint64_t& nIn) : n(nIn) { }
explicit CCompactSize(uint64_t& nIn) : n(nIn) { }
template<typename Stream>
void Serialize(Stream &s) const {
@ -439,7 +439,7 @@ class LimitedString @@ -439,7 +439,7 @@ class LimitedString
protected:
std::string& string;
public:
LimitedString(std::string& _string) : string(_string) {}
explicit LimitedString(std::string& _string) : string(_string) {}
template<typename Stream>
void Unserialize(Stream& s)

4
src/support/lockedpool.h

@ -150,7 +150,7 @@ public: @@ -150,7 +150,7 @@ public:
* 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<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr);
explicit LockedPool(std::unique_ptr<LockedPageAllocator> allocator, LockingFailed_Callback lf_cb_in = nullptr);
~LockedPool();
/** Allocate size bytes from this arena.
@ -217,7 +217,7 @@ public: @@ -217,7 +217,7 @@ public:
}
private:
LockedPoolManager(std::unique_ptr<LockedPageAllocator> allocator);
explicit LockedPoolManager(std::unique_ptr<LockedPageAllocator> allocator);
/** Create a new LockedPoolManager specialized to the OS */
static void CreateInstance();

4
src/sync.h

@ -196,7 +196,7 @@ private: @@ -196,7 +196,7 @@ private:
int value;
public:
CSemaphore(int init) : value(init) {}
explicit CSemaphore(int init) : value(init) {}
void wait()
{
@ -267,7 +267,7 @@ public: @@ -267,7 +267,7 @@ public:
CSemaphoreGrant() : sem(nullptr), fHaveGrant(false) {}
CSemaphoreGrant(CSemaphore& sema, bool fTry = false) : sem(&sema), fHaveGrant(false)
explicit CSemaphoreGrant(CSemaphore& sema, bool fTry = false) : sem(&sema), fHaveGrant(false)
{
if (fTry)
TryAcquire();

4
src/test/base58_tests.cpp

@ -78,7 +78,7 @@ class TestAddrTypeVisitor : public boost::static_visitor<bool> @@ -78,7 +78,7 @@ class TestAddrTypeVisitor : public boost::static_visitor<bool>
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");
@ -99,7 +99,7 @@ class TestPayloadVisitor : public boost::static_visitor<bool> @@ -99,7 +99,7 @@ class TestPayloadVisitor : public boost::static_visitor<bool>
private:
std::vector<unsigned char> exp_payload;
public:
TestPayloadVisitor(std::vector<unsigned char> &_exp_payload) : exp_payload(_exp_payload) { }
explicit TestPayloadVisitor(std::vector<unsigned char> &_exp_payload) : exp_payload(_exp_payload) { }
bool operator()(const CKeyID &id) const
{
uint160 exp_key(exp_payload);

2
src/test/bip32_tests.cpp

@ -24,7 +24,7 @@ struct TestVector { @@ -24,7 +24,7 @@ struct TestVector {
std::string strHexMaster;
std::vector<TestDerivation> 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.push_back(TestDerivation());

4
src/test/blockencodings_tests.cpp

@ -118,12 +118,12 @@ public: @@ -118,12 +118,12 @@ public:
std::vector<uint64_t> shorttxids;
std::vector<PrefilledTransaction> 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, true)) {}
uint64_t GetShortID(const uint256& txhash) const {

2
src/test/coins_tests.cpp

@ -74,7 +74,7 @@ public: @@ -74,7 +74,7 @@ public:
class CCoinsViewCacheTest : public CCoinsViewCache
{
public:
CCoinsViewCacheTest(CCoinsView* _base) : CCoinsViewCache(_base) {}
explicit CCoinsViewCacheTest(CCoinsView* _base) : CCoinsViewCache(_base) {}
void SelfTest() const
{

2
src/test/dbwrapper_tests.cpp

@ -231,7 +231,7 @@ struct StringContentsSerializer { @@ -231,7 +231,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;

4
src/test/test_bitcoin.h

@ -41,7 +41,7 @@ static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); } @@ -41,7 +41,7 @@ static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); }
struct BasicTestingSetup {
ECCVerifyHandle globalVerifyHandle;
BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
explicit BasicTestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
~BasicTestingSetup();
};
@ -56,7 +56,7 @@ struct TestingSetup: public BasicTestingSetup { @@ -56,7 +56,7 @@ struct TestingSetup: public BasicTestingSetup {
CConnman* connman;
CScheduler scheduler;
TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
explicit TestingSetup(const std::string& chainName = CBaseChainParams::MAIN);
~TestingSetup();
};

8
src/tinyformat.h

@ -167,7 +167,7 @@ namespace tinyformat { @@ -167,7 +167,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) {
}
};
@ -498,7 +498,7 @@ class FormatArg @@ -498,7 +498,7 @@ class FormatArg
FormatArg() {}
template<typename T>
FormatArg(const T& value)
explicit FormatArg(const T& value)
: m_value(static_cast<const void*>(&value)),
m_formatImpl(&formatImpl<T>),
m_toIntImpl(&toIntImpl<T>)
@ -867,7 +867,7 @@ class FormatListN : public FormatList @@ -867,7 +867,7 @@ class FormatListN : public FormatList
public:
#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
template<typename... Args>
FormatListN(const Args&... args)
explicit FormatListN(const Args&... args)
: FormatList(&m_formatterStore[0], N),
m_formatterStore { FormatArg(args)... }
{ static_assert(sizeof...(args) == N, "Number of args must be N"); }
@ -876,7 +876,7 @@ class FormatListN : public FormatList @@ -876,7 +876,7 @@ class FormatListN : public FormatList
# define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \
\
template<TINYFORMAT_ARGTYPES(n)> \
FormatListN(TINYFORMAT_VARARGS(n)) \
explicit FormatListN(TINYFORMAT_VARARGS(n)) \
: FormatList(&m_formatterStore[0], n) \
{ assert(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \
\

2
src/torcontrol.cpp

@ -76,7 +76,7 @@ public: @@ -76,7 +76,7 @@ public:
/** Create a new TorControlConnection.
*/
TorControlConnection(struct event_base *base);
explicit TorControlConnection(struct event_base *base);
~TorControlConnection();
/**

2
src/txdb.cpp

@ -35,7 +35,7 @@ namespace { @@ -35,7 +35,7 @@ namespace {
struct CoinEntry {
COutPoint* outpoint;
char key;
CoinEntry(const COutPoint* ptr) : outpoint(const_cast<COutPoint*>(ptr)), key(DB_COIN) {}
explicit CoinEntry(const COutPoint* ptr) : outpoint(const_cast<COutPoint*>(ptr)), key(DB_COIN) {}
template<typename Stream>
void Serialize(Stream &s) const {

4
src/txdb.h

@ -69,7 +69,7 @@ class CCoinsViewDB : public CCoinsView @@ -69,7 +69,7 @@ class CCoinsViewDB : public CCoinsView
protected:
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 +109,7 @@ private: @@ -109,7 +109,7 @@ private:
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&);
void operator=(const CBlockTreeDB&);

6
src/txmempool.h

@ -167,7 +167,7 @@ struct update_ancestor_state @@ -167,7 +167,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); }
@ -177,7 +177,7 @@ private: @@ -177,7 +177,7 @@ private:
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); }
@ -501,7 +501,7 @@ public: @@ -501,7 +501,7 @@ public:
/** Create a new CTxMemPool.
*/
CTxMemPool(CBlockPolicyEstimator* estimator = nullptr);
explicit CTxMemPool(CBlockPolicyEstimator* estimator = nullptr);
/**
* If sanity-checking is turned on, check makes sure the pool is

4
src/uint256.h

@ -111,7 +111,7 @@ public: @@ -111,7 +111,7 @@ public:
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<unsigned char>& vch) : base_blob<160>(vch) {}
};
@ -123,7 +123,7 @@ public: @@ -123,7 +123,7 @@ public:
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<unsigned char>& vch) : base_blob<256>(vch) {}
/** A cheap hash function that just returns 64 bits from the result, it can be

4
src/undo.h

@ -33,7 +33,7 @@ public: @@ -33,7 +33,7 @@ public:
::Serialize(s, CTxOutCompressor(REF(txout->out)));
}
TxInUndoSerializer(const Coin* coin) : txout(coin) {}
explicit TxInUndoSerializer(const Coin* coin) : txout(coin) {}
};
class TxInUndoDeserializer
@ -57,7 +57,7 @@ public: @@ -57,7 +57,7 @@ public:
::Unserialize(s, REF(CTxOutCompressor(REF(txout->out))));
}
TxInUndoDeserializer(Coin* coin) : txout(coin) {}
explicit TxInUndoDeserializer(Coin* coin) : txout(coin) {}
};
static const size_t MIN_TRANSACTION_INPUT_WEIGHT = WITNESS_SCALE_FACTOR * ::GetSerializeSize(CTxIn(), SER_NETWORK, PROTOCOL_VERSION);

2
src/univalue/lib/univalue_utffilter.h

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
class JSONUTF8StringFilter
{
public:
JSONUTF8StringFilter(std::string &s):
explicit JSONUTF8StringFilter(std::string &s):
str(s), is_valid(true), codepoint(0), state(0), surpair(0)
{
}

4
src/validation.cpp

@ -1563,7 +1563,7 @@ private: @@ -1563,7 +1563,7 @@ private:
int bit;
public:
WarningBitsConditionChecker(int bitIn) : bit(bitIn) {}
explicit WarningBitsConditionChecker(int bitIn) : bit(bitIn) {}
int64_t BeginTime(const Consensus::Params& params) const override { return 0; }
int64_t EndTime(const Consensus::Params& params) const override { return std::numeric_limits<int64_t>::max(); }
@ -2135,7 +2135,7 @@ private: @@ -2135,7 +2135,7 @@ private:
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));
}

2
src/validationinterface.cpp

@ -30,7 +30,7 @@ struct MainSignalsInstance { @@ -30,7 +30,7 @@ struct MainSignalsInstance {
// our own queue here :(
SingleThreadedSchedulerClient m_schedulerClient;
MainSignalsInstance(CScheduler *pscheduler) : m_schedulerClient(pscheduler) {}
explicit MainSignalsInstance(CScheduler *pscheduler) : m_schedulerClient(pscheduler) {}
};
static CMainSignals g_signals;

2
src/versionbits.cpp

@ -185,7 +185,7 @@ protected: @@ -185,7 +185,7 @@ protected:
}
public:
VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {}
explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {}
uint32_t Mask(const Consensus::Params& params) const { return ((uint32_t)1) << params.vDeployments[id].bit; }
};

2
src/wallet/rpcwallet.cpp

@ -1123,7 +1123,7 @@ public: @@ -1123,7 +1123,7 @@ public:
CWallet * const pwallet;
CScriptID result;
Witnessifier(CWallet *_pwallet) : pwallet(_pwallet) {}
explicit Witnessifier(CWallet *_pwallet) : pwallet(_pwallet) {}
bool operator()(const CNoDestination &dest) const { return false; }

2
src/wallet/test/wallet_test_fixture.h

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
/** 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();
};

8
src/wallet/wallet.h

@ -208,7 +208,7 @@ public: @@ -208,7 +208,7 @@ public:
Init();
}
CMerkleTx(CTransactionRef arg)
explicit CMerkleTx(CTransactionRef arg)
{
SetTx(std::move(arg));
Init();
@ -548,7 +548,7 @@ public: @@ -548,7 +548,7 @@ public:
//! todo: add something to note what created it (user, getnewaddress, change)
//! maybe should have a map<string, string> property map
CWalletKey(int64_t nExpires=0);
explicit CWalletKey(int64_t nExpires=0);
ADD_SERIALIZE_METHODS;
@ -765,7 +765,7 @@ public: @@ -765,7 +765,7 @@ public:
}
// Create wallet with passed-in database handle
CWallet(std::unique_ptr<CWalletDBWrapper> dbw_in) : dbw(std::move(dbw_in))
explicit CWallet(std::unique_ptr<CWalletDBWrapper> dbw_in) : dbw(std::move(dbw_in))
{
SetNull();
}
@ -1145,7 +1145,7 @@ protected: @@ -1145,7 +1145,7 @@ protected:
CPubKey vchPubKey;
bool fInternal;
public:
CReserveKey(CWallet* pwalletIn)
explicit CReserveKey(CWallet* pwalletIn)
{
nIndex = -1;
pwallet = pwalletIn;

4
src/wallet/walletdb.h

@ -105,7 +105,7 @@ public: @@ -105,7 +105,7 @@ public:
{
SetNull();
}
CKeyMetadata(int64_t nCreateTime_)
explicit CKeyMetadata(int64_t nCreateTime_)
{
SetNull();
nCreateTime = nCreateTime_;
@ -162,7 +162,7 @@ private: @@ -162,7 +162,7 @@ private:
}
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)
{

Loading…
Cancel
Save