diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml index 4e5c9e59de96..28975eae73bf 100644 --- a/.github/workflows/semantic-pull-request.yml +++ b/.github/workflows/semantic-pull-request.yml @@ -30,6 +30,7 @@ jobs: build guix ci + lint chore revert trivial diff --git a/src/.clang-tidy b/src/.clang-tidy index 76978140ecd7..ad82694d875d 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -26,3 +26,4 @@ readability-redundant-string-init, CheckOptions: - key: performance-move-const-arg.CheckTriviallyCopyableMove value: false +HeaderFilterRegex: '.' diff --git a/src/active/dkgsessionhandler.cpp b/src/active/dkgsessionhandler.cpp index c0ed65b75402..1c74095ad7d2 100644 --- a/src/active/dkgsessionhandler.cpp +++ b/src/active/dkgsessionhandler.cpp @@ -343,7 +343,7 @@ static void RelayInvToParticipants(const CDKGSession& session, const CConnman& c "HasMasternodeQuorumNodes[%d] for quorumHash[%s] forMember[%s] relayMembers[%s]", inv.ToString(), relayMembers.size(), connman.GetNodeCount(ConnectionDirection::Both), connman.GetNetworkActive(), - connman.HasMasternodeQuorumNodes(session.GetParams().type, session.BlockIndex()->GetBlockHash()), + connman.HasMasternodeQuorumNodes(session.GetType(), session.BlockIndex()->GetBlockHash()), session.BlockIndex()->GetBlockHash().ToString(), session.ProTx().ToString().substr(0, 4), ss.str()); std::stringstream ss2; diff --git a/src/bls/bls.h b/src/bls/bls.h index a99cec3114cf..6c3a7f2010e9 100644 --- a/src/bls/bls.h +++ b/src/bls/bls.h @@ -390,7 +390,7 @@ class CBLSLazyWrapper private: mutable std::mutex mutex; - mutable std::array vecBytes; + mutable std::array vecBytes{}; mutable BLSObject obj; mutable bool objInitialized{false}; @@ -403,7 +403,6 @@ class CBLSLazyWrapper public: CBLSLazyWrapper() : - vecBytes{}, bufLegacyScheme(bls::bls_legacy_scheme.load()) {} diff --git a/src/chain.h b/src/chain.h index 47d1e3096774..4236e5a7adff 100644 --- a/src/chain.h +++ b/src/chain.h @@ -35,7 +35,7 @@ static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME; */ static constexpr int64_t MAX_BLOCK_TIME_GAP = 25 * 60; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class CBlockFileInfo { diff --git a/src/coinjoin/coinjoin.h b/src/coinjoin/coinjoin.h index 9a15be8b6c03..461aa16ec991 100644 --- a/src/coinjoin/coinjoin.h +++ b/src/coinjoin/coinjoin.h @@ -34,7 +34,7 @@ class CChainLocksHandler; class CInstantSendManager; } // namespace llmq -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) // timeouts static constexpr int COINJOIN_AUTO_TIMEOUT_MIN = 5; diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp index 29a4ad906fc7..a2f7c6e1563b 100644 --- a/src/crypto/ripemd160.cpp +++ b/src/crypto/ripemd160.cpp @@ -239,7 +239,7 @@ void Transform(uint32_t* s, const unsigned char* chunk) ////// RIPEMD160 -CRIPEMD160::CRIPEMD160() : bytes(0) +CRIPEMD160::CRIPEMD160() { ripemd160::Initialize(s); } diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h index 025121f24ad1..d4a526e5587f 100644 --- a/src/crypto/ripemd160.h +++ b/src/crypto/ripemd160.h @@ -14,7 +14,7 @@ class CRIPEMD160 private: uint32_t s[5]; unsigned char buf[64]; - uint64_t bytes; + uint64_t bytes{0}; public: static const size_t OUTPUT_SIZE = 20; diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index 1fb9bb2b72f2..2610108f6075 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -146,7 +146,7 @@ void Transform(uint32_t* s, const unsigned char* chunk) ////// SHA1 -CSHA1::CSHA1() : bytes(0) +CSHA1::CSHA1() { sha1::Initialize(s); } diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h index f1b7dffab43d..e991362393cf 100644 --- a/src/crypto/sha1.h +++ b/src/crypto/sha1.h @@ -14,7 +14,7 @@ class CSHA1 private: uint32_t s[5]; unsigned char buf[64]; - uint64_t bytes; + uint64_t bytes{0}; public: static const size_t OUTPUT_SIZE = 20; diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 884719a1b097..c99b5697366d 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -690,7 +690,7 @@ std::string SHA256AutoDetect(sha256_implementation::UseImplementation use_implem ////// SHA-256 -CSHA256::CSHA256() : bytes(0) +CSHA256::CSHA256() { sha256::Initialize(s); } diff --git a/src/crypto/sha256.h b/src/crypto/sha256.h index 60b2237a7430..456c65746c32 100644 --- a/src/crypto/sha256.h +++ b/src/crypto/sha256.h @@ -15,7 +15,7 @@ class CSHA256 private: uint32_t s[8]; unsigned char buf[64]; - uint64_t bytes; + uint64_t bytes{0}; public: static const size_t OUTPUT_SIZE = 32; diff --git a/src/crypto/sha512.cpp b/src/crypto/sha512.cpp index 59b79609dd8c..5e4a1c3cc329 100644 --- a/src/crypto/sha512.cpp +++ b/src/crypto/sha512.cpp @@ -151,7 +151,7 @@ void Transform(uint64_t* s, const unsigned char* chunk) ////// SHA-512 -CSHA512::CSHA512() : bytes(0) +CSHA512::CSHA512() { sha512::Initialize(s); } diff --git a/src/crypto/sha512.h b/src/crypto/sha512.h index 7356dff6d9b3..4d5815afa7c4 100644 --- a/src/crypto/sha512.h +++ b/src/crypto/sha512.h @@ -14,7 +14,7 @@ class CSHA512 private: uint64_t s[8]; unsigned char buf[128]; - uint64_t bytes; + uint64_t bytes{0}; public: static constexpr size_t OUTPUT_SIZE = 64; diff --git a/src/cuckoocache.h b/src/cuckoocache.h index 22c06d89735a..833254b40b36 100644 --- a/src/cuckoocache.h +++ b/src/cuckoocache.h @@ -164,7 +164,7 @@ class cache std::vector table; /** size stores the total available slots in the hash table */ - uint32_t size; + uint32_t size{0}; /** The bit_packed_atomic_flags array is marked mutable because we want * garbage collection to be allowed to occur from const methods */ @@ -181,7 +181,7 @@ class cache * decremented on insert and reset to the new number of inserts which would * cause the epoch to reach epoch_size when it reaches zero. */ - uint32_t epoch_heuristic_counter; + uint32_t epoch_heuristic_counter{0}; /** epoch_size is set to be the number of elements supposed to be in a * epoch. When the number of non-erased elements in an epoch @@ -191,12 +191,12 @@ class cache * one "dead" which has been erased, one "dying" which has been marked to be * erased next, and one "living" which new inserts add to. */ - uint32_t epoch_size; + uint32_t epoch_size{0}; /** depth_limit determines how many elements insert should try to replace. * Should be set to log2(n). */ - uint8_t depth_limit; + uint8_t depth_limit{0}; /** hash_function is a const instance of the hash function. It cannot be * static or initialized at call time as it may have internal state (such as @@ -320,8 +320,7 @@ class cache /** You must always construct a cache with some elements via a subsequent * call to setup or setup_bytes, otherwise operations may segfault. */ - cache() : table(), size(), collection_flags(0), epoch_flags(), - epoch_heuristic_counter(), epoch_size(), depth_limit(0), hash_function() + cache() : table(), collection_flags(0), epoch_flags(), hash_function() { } diff --git a/src/cxxtimer.hpp b/src/cxxtimer.hpp index 0b58b5d97134..509d6c5f82d4 100644 --- a/src/cxxtimer.hpp +++ b/src/cxxtimer.hpp @@ -118,20 +118,17 @@ class Timer { typename duration_t::rep count() const; private: - - bool started_; - bool paused_; - std::chrono::steady_clock::time_point reference_; - std::chrono::duration accumulated_; + bool started_{false}; + bool paused_{false}; + std::chrono::steady_clock::time_point reference_{std::chrono::steady_clock::now()}; + std::chrono::duration accumulated_{std::chrono::duration(0)}; }; } -inline cxxtimer::Timer::Timer(bool start) : - started_(false), paused_(false), - reference_(std::chrono::steady_clock::now()), - accumulated_(std::chrono::duration(0)) { +inline cxxtimer::Timer::Timer(bool start) +{ if (start) { this->start(); } diff --git a/src/dbwrapper.h b/src/dbwrapper.h index bd6e847180a6..9f04c8523266 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -79,13 +79,13 @@ class CDBBatch CDataStream ssKey; CDataStream ssValue; - size_t size_estimate; + size_t size_estimate{0}; public: /** * @param[in] _parent CDBWrapper that this batch is to be submitted to */ - explicit 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) {}; void Clear() { diff --git a/src/evo/deterministicmns.h b/src/evo/deterministicmns.h index 1bdcf7343e96..4a0661633ad7 100644 --- a/src/evo/deterministicmns.h +++ b/src/evo/deterministicmns.h @@ -40,7 +40,7 @@ class CSpecialTxProcessor; class TxValidationState; struct RPCResult; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class CDeterministicMN { diff --git a/src/evo/dmn_types.h b/src/evo/dmn_types.h index d532c6b3a667..bdf79e84c4f1 100644 --- a/src/evo/dmn_types.h +++ b/src/evo/dmn_types.h @@ -53,7 +53,7 @@ constexpr auto Invalid = mntype_struct{ } // namespace dmn_types -[[nodiscard]] constexpr const dmn_types::mntype_struct GetMnType(MnType type) +[[nodiscard]] constexpr dmn_types::mntype_struct GetMnType(MnType type) { switch (type) { case MnType::Regular: return dmn_types::Regular; diff --git a/src/evo/mnhftx.h b/src/evo/mnhftx.h index 2f399412c24c..f1606d226b44 100644 --- a/src/evo/mnhftx.h +++ b/src/evo/mnhftx.h @@ -46,7 +46,7 @@ class MNHFTx SERIALIZE_METHODS(MNHFTx, obj) { READWRITE(obj.versionBit, obj.quorumHash); - READWRITE(CBLSSignatureVersionWrapper(const_cast(obj.sig), /* fLegacy= */ false)); + READWRITE(CBLSSignatureVersionWrapper(const_cast(obj.sig), /*legacy=*/false)); } std::string ToString() const; diff --git a/src/evo/smldiff.h b/src/evo/smldiff.h index 0154403d840b..36eb066f73a7 100644 --- a/src/evo/smldiff.h +++ b/src/evo/smldiff.h @@ -29,7 +29,7 @@ class CQuorumBlockProcessor; class CQuorumManager; } // namespace llmq -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) /// P2P messages diff --git a/src/evo/specialtxman.h b/src/evo/specialtxman.h index de293d0dfaba..4980c11324aa 100644 --- a/src/evo/specialtxman.h +++ b/src/evo/specialtxman.h @@ -33,7 +33,7 @@ class CQuorumManager; class CQuorumSnapshotManager; } // namespace llmq -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class CSpecialTxProcessor { diff --git a/src/governance/classes.h b/src/governance/classes.h index 50c7f1e2ef9c..f68691bb03ce 100644 --- a/src/governance/classes.h +++ b/src/governance/classes.h @@ -102,7 +102,7 @@ class CSuperblock : public CGovernanceObject return nBlockHeight; } - const uint256 GetGovernanceObjHash() const { return nGovObjHash; } + uint256 GetGovernanceObjHash() const { return nGovObjHash; } int CountPayments() const { return (int)vecPayments.size(); } bool GetPayment(int nPaymentIndex, CGovernancePayment& paymentRet); diff --git a/src/governance/governance.h b/src/governance/governance.h index a8d5f324acbc..a90dc0e250ca 100644 --- a/src/governance/governance.h +++ b/src/governance/governance.h @@ -52,25 +52,20 @@ using vote_time_pair_t = std::pair; static constexpr int RATE_BUFFER_SIZE = 5; static constexpr bool DEFAULT_GOVERNANCE_ENABLE{true}; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class CRateCheckBuffer { private: std::vector vecTimestamps; - int nDataStart; - - int nDataEnd; - - bool fBufferEmpty; + int nDataStart{0}; + int nDataEnd{0}; + bool fBufferEmpty{true}; public: CRateCheckBuffer() : - vecTimestamps(RATE_BUFFER_SIZE), - nDataStart(0), - nDataEnd(0), - fBufferEmpty(true) + vecTimestamps(RATE_BUFFER_SIZE) { } diff --git a/src/governance/object.h b/src/governance/object.h index 9e149e4ac9af..f1df2ecd069a 100644 --- a/src/governance/object.h +++ b/src/governance/object.h @@ -24,7 +24,7 @@ class ChainstateManager; class CMasternodeMetaMan; struct RPCResult; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) static constexpr double GOVERNANCE_FILTER_FP_RATE = 0.001; static constexpr CAmount GOVERNANCE_PROPOSAL_FEE_TX = (1 * COIN); diff --git a/src/governance/validators.cpp b/src/governance/validators.cpp index bbe10d90439d..498796da955d 100644 --- a/src/governance/validators.cpp +++ b/src/governance/validators.cpp @@ -18,7 +18,6 @@ const size_t MAX_NAME_SIZE = 40; CProposalValidator::CProposalValidator(const std::string& strHexData, bool fAllowScript) : objJSON(UniValue::VOBJ), - fJSONValid(false), fAllowScript(fAllowScript), strErrorMessages() { diff --git a/src/governance/validators.h b/src/governance/validators.h index b7daafe52c9f..39685e223d80 100644 --- a/src/governance/validators.h +++ b/src/governance/validators.h @@ -13,7 +13,7 @@ class CProposalValidator { private: UniValue objJSON; - bool fJSONValid; + bool fJSONValid{false}; bool fAllowScript; std::string strErrorMessages; diff --git a/src/governance/votedb.cpp b/src/governance/votedb.cpp index 6ffc8eeffffd..b1768f8b0346 100644 --- a/src/governance/votedb.cpp +++ b/src/governance/votedb.cpp @@ -5,7 +5,6 @@ #include CGovernanceObjectVoteFile::CGovernanceObjectVoteFile() : - nMemoryVotes(0), listVotes(), mapVoteIndex() { diff --git a/src/governance/votedb.h b/src/governance/votedb.h index 646544c3de77..169196cb9ff8 100644 --- a/src/governance/votedb.h +++ b/src/governance/votedb.h @@ -32,7 +32,7 @@ class CGovernanceObjectVoteFile using vote_m_t = std::map; private: - int nMemoryVotes; + int nMemoryVotes{0}; vote_l_t listVotes; diff --git a/src/key.h b/src/key.h index babffd406b0a..c1688815a517 100644 --- a/src/key.h +++ b/src/key.h @@ -48,10 +48,10 @@ class CKey private: //! Whether this private key is valid. We check for correctness when modifying the key //! data, so fValid should always correspond to the actual state. - bool fValid; + bool fValid{false}; //! Whether the public key corresponding to this private key is (to be) compressed. - bool fCompressed; + bool fCompressed{false}; //! The actual byte data std::vector > keydata; @@ -61,7 +61,7 @@ class CKey public: //! Construct an invalid private key. - CKey() : fValid(false), fCompressed(false) + CKey() { // Important: vch must be 32 bytes in length to not break serialization keydata.resize(32); diff --git a/src/llmq/blockprocessor.h b/src/llmq/blockprocessor.h index e44506131036..15ca83307117 100644 --- a/src/llmq/blockprocessor.h +++ b/src/llmq/blockprocessor.h @@ -31,7 +31,7 @@ class CDeterministicMNManager; class CEvoDB; class CNode; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) namespace llmq { diff --git a/src/llmq/dkgsession.h b/src/llmq/dkgsession.h index 16b2e1416653..f9a4ce756e92 100644 --- a/src/llmq/dkgsession.h +++ b/src/llmq/dkgsession.h @@ -389,7 +389,7 @@ class CDKGSession [[nodiscard]] const Uint256HashSet& RelayMembers() const { return relayMembers; } [[nodiscard]] const CBlockIndex* BlockIndex() const { return m_quorum_base_block_index; } [[nodiscard]] const uint256& ProTx() const { return myProTxHash; } - [[nodiscard]] const Consensus::LLMQParams GetParams() const { return params; } + [[nodiscard]] Consensus::LLMQType GetType() const { return params.type; } protected: virtual bool MaybeDecrypt(const CBLSIESMultiRecipientObjects& obj, size_t idx, diff --git a/src/masternode/meta.h b/src/masternode/meta.h index 5e7729a9390f..4342e65607c1 100644 --- a/src/masternode/meta.h +++ b/src/masternode/meta.h @@ -127,7 +127,7 @@ class MasternodeMetaStore std::vector tmpUsedMasternodes; s >> tmpMetaInfo >> nDsqCount >> tmpUsedMasternodes; for (auto& mm : tmpMetaInfo) { - metaInfos.emplace(mm.m_protx_hash, CMasternodeMetaInfo{std::move(mm)}); + metaInfos.emplace(mm.m_protx_hash, CMasternodeMetaInfo{mm}); } // Convert vector to deque and build unordered_set for O(1) lookups diff --git a/src/node/blockstorage.h b/src/node/blockstorage.h index b627c26162fd..2cfae856c2cc 100644 --- a/src/node/blockstorage.h +++ b/src/node/blockstorage.h @@ -16,7 +16,7 @@ #include #include -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class ArgsManager; class BlockValidationState; diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index e0586637450a..03b629e7b9e6 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -543,7 +543,6 @@ bool CBlockPolicyEstimator::_removeTx(const uint256& hash, bool inBlock) } CBlockPolicyEstimator::CBlockPolicyEstimator() - : nBestSeenHeight(0), firstRecordedHeight(0), historicalFirst(0), historicalBest(0), trackedTxs(0), untrackedTxs(0) { static_assert(MIN_BUCKET_FEERATE > 0, "Min feerate must be nonzero"); size_t bucketIndex = 0; diff --git a/src/policy/fees.h b/src/policy/fees.h index 3a0ed2dc1b11..45bc40ab75c0 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -240,16 +240,16 @@ class CBlockPolicyEstimator private: mutable Mutex m_cs_fee_estimator; - unsigned int nBestSeenHeight GUARDED_BY(m_cs_fee_estimator); - unsigned int firstRecordedHeight GUARDED_BY(m_cs_fee_estimator); - unsigned int historicalFirst GUARDED_BY(m_cs_fee_estimator); - unsigned int historicalBest GUARDED_BY(m_cs_fee_estimator); + unsigned int nBestSeenHeight GUARDED_BY(m_cs_fee_estimator){0}; + unsigned int firstRecordedHeight GUARDED_BY(m_cs_fee_estimator){0}; + unsigned int historicalFirst GUARDED_BY(m_cs_fee_estimator){0}; + unsigned int historicalBest GUARDED_BY(m_cs_fee_estimator){0}; struct TxStatsInfo { - unsigned int blockHeight; - unsigned int bucketIndex; - TxStatsInfo() : blockHeight(0), bucketIndex(0) {} + unsigned int blockHeight{0}; + unsigned int bucketIndex{0}; + TxStatsInfo() {} }; // map of txids to information about that transaction @@ -260,8 +260,8 @@ class CBlockPolicyEstimator std::unique_ptr shortStats PT_GUARDED_BY(m_cs_fee_estimator); std::unique_ptr longStats PT_GUARDED_BY(m_cs_fee_estimator); - unsigned int trackedTxs GUARDED_BY(m_cs_fee_estimator); - unsigned int untrackedTxs GUARDED_BY(m_cs_fee_estimator); + unsigned int trackedTxs GUARDED_BY(m_cs_fee_estimator){0}; + unsigned int untrackedTxs GUARDED_BY(m_cs_fee_estimator){0}; std::vector buckets GUARDED_BY(m_cs_fee_estimator); // The upper-bound of the range for the bucket (inclusive) std::map bucketMap GUARDED_BY(m_cs_fee_estimator); // Map of bucket upper-bound to index into all vectors by bucket diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index 9f2b162eb948..7a96643225df 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -67,7 +67,6 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel AddressBookPage::AddressBookPage(Mode _mode, Tabs _tab, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::AddressBookPage), - model(nullptr), mode(_mode), tab(_tab) { diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h index 2446443e5d3f..a21c6830f06f 100644 --- a/src/qt/addressbookpage.h +++ b/src/qt/addressbookpage.h @@ -48,7 +48,7 @@ public Q_SLOTS: private: Ui::AddressBookPage *ui; - AddressTableModel *model; + AddressTableModel* model{nullptr}; Mode mode; Tabs tab; QString returnValue; diff --git a/src/qt/appearancewidget.h b/src/qt/appearancewidget.h index 1929d0b6b33a..24b2689c9a66 100644 --- a/src/qt/appearancewidget.h +++ b/src/qt/appearancewidget.h @@ -24,7 +24,7 @@ class AppearanceWidget : public QWidget Q_OBJECT public: - explicit AppearanceWidget(QWidget* parent = 0); + explicit AppearanceWidget(QWidget* parent = nullptr); ~AppearanceWidget(); void setModel(OptionsModel* model); diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 9f2e6b41533b..ad4f0f8f84ff 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -25,8 +25,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode _mode, QWidget *parent, SecureStri QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::AskPassphraseDialog), mode(_mode), - model(nullptr), - fCapsLock(false), m_passphrase_out(passphrase_out) { ui->setupUi(this); diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h index 3157e24ef050..88d49f5e7fdb 100644 --- a/src/qt/askpassphrasedialog.h +++ b/src/qt/askpassphrasedialog.h @@ -39,8 +39,8 @@ class AskPassphraseDialog : public QDialog private: Ui::AskPassphraseDialog *ui; Mode mode; - WalletModel *model; - bool fCapsLock; + WalletModel* model{nullptr}; + bool fCapsLock{false}; SecureString* m_passphrase_out; private Q_SLOTS: diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index aa895e627754..49be7fe28714 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -231,13 +231,8 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons static int qt_argc = 1; static const char* qt_argv = "dash-qt"; -BitcoinApplication::BitcoinApplication(): - QApplication(qt_argc, const_cast(&qt_argv)), - optionsModel(nullptr), - clientModel(nullptr), - window(nullptr), - pollShutdownTimer(nullptr), - returnValue(0) +BitcoinApplication::BitcoinApplication() + : QApplication(qt_argc, const_cast(&qt_argv)) { RegisterMetaTypes(); // Qt runs setlocale(LC_ALL, "") on initialization. diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 0cf8ee03bcfc..077253c3bd91 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -93,15 +93,15 @@ public Q_SLOTS: private: std::optional m_executor; - OptionsModel *optionsModel; - ClientModel *clientModel; - BitcoinGUI *window; - QTimer *pollShutdownTimer; + OptionsModel* optionsModel{nullptr}; + ClientModel* clientModel{nullptr}; + BitcoinGUI* window{nullptr}; + QTimer* pollShutdownTimer{nullptr}; #ifdef ENABLE_WALLET PaymentServer* paymentServer{nullptr}; WalletController* m_wallet_controller{nullptr}; #endif - int returnValue; + int returnValue{0}; std::unique_ptr shutdownWindow; SplashScreen* m_splash = nullptr; std::unique_ptr m_node; diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index d71e08fd2ee8..9b6391149076 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -185,9 +185,8 @@ class AmountLineEdit: public QLineEdit #include -BitcoinAmountField::BitcoinAmountField(QWidget *parent) : - QWidget(parent), - amount(nullptr) +BitcoinAmountField::BitcoinAmountField(QWidget* parent) + : QWidget(parent) { amount = new AmountLineEdit(this); amount->setLocale(QLocale::c()); diff --git a/src/qt/bitcoinamountfield.h b/src/qt/bitcoinamountfield.h index 5bb84acc537c..d5ea9b9b4469 100644 --- a/src/qt/bitcoinamountfield.h +++ b/src/qt/bitcoinamountfield.h @@ -72,7 +72,7 @@ class BitcoinAmountField: public QWidget bool eventFilter(QObject *object, QEvent *event) override; private: - AmountLineEdit *amount; + AmountLineEdit* amount{nullptr}; BitcoinUnits *units; void unitChanged(int idx); diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index db33a094ea82..249e4d25d751 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -2144,9 +2144,7 @@ bool BitcoinGUI::isPrivacyModeActivated() const return m_mask_values_action->isChecked(); } -UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : - optionsModel(nullptr), - menu(nullptr) +UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() { createContextMenu(); setToolTip(tr("Unit to show amounts in. Click to select another unit.")); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 26f73eda3e60..576605443e7c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -406,8 +406,8 @@ class UnitDisplayStatusBarControl : public QLabel void mousePressEvent(QMouseEvent *event) override; private: - OptionsModel *optionsModel; - QMenu* menu; + OptionsModel* optionsModel{nullptr}; + QMenu* menu{nullptr}; /** Shows context menu with Display Unit options by the mouse coordinates */ void onDisplayUnitsClicked(const QPoint& point); diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 94020ba5a3a7..ce69faa428d8 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -38,8 +38,6 @@ ClientModel::ClientModel(interfaces::Node& node, OptionsModel *_optionsModel, QO QObject(parent), m_node(node), optionsModel(_optionsModel), - peerTableModel(nullptr), - banTableModel(nullptr), m_thread(new QThread(this)) { cachedBestHeaderHeight = -1; diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h index dcd2ba43712c..fbf325fbd8b4 100644 --- a/src/qt/clientmodel.h +++ b/src/qt/clientmodel.h @@ -108,9 +108,9 @@ class ClientModel : public QObject interfaces::Node& m_node; std::vector> m_event_handlers; OptionsModel *optionsModel; - PeerTableModel *peerTableModel; + PeerTableModel* peerTableModel{nullptr}; PeerTableSortProxy* m_peer_table_sort_proxy{nullptr}; - BanTableModel *banTableModel; + BanTableModel* banTableModel{nullptr}; //! A thread to interact with m_node asynchronously QThread* const m_thread; diff --git a/src/qt/csvmodelwriter.cpp b/src/qt/csvmodelwriter.cpp index 6b89497f6d4d..52cc87dc7b60 100644 --- a/src/qt/csvmodelwriter.cpp +++ b/src/qt/csvmodelwriter.cpp @@ -8,9 +8,9 @@ #include #include -CSVModelWriter::CSVModelWriter(const QString &_filename, QObject *parent) : - QObject(parent), - filename(_filename), model(nullptr) +CSVModelWriter::CSVModelWriter(const QString& _filename, QObject* parent) + : QObject(parent), + filename(_filename) { } diff --git a/src/qt/csvmodelwriter.h b/src/qt/csvmodelwriter.h index ad247b6859b8..a1e77826a8ca 100644 --- a/src/qt/csvmodelwriter.h +++ b/src/qt/csvmodelwriter.h @@ -32,7 +32,7 @@ class CSVModelWriter : public QObject private: QString filename; - const QAbstractItemModel *model; + const QAbstractItemModel* model{nullptr}; struct Column { diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index 179474587854..ee0711247a6a 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -12,12 +12,11 @@ #include #include -EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) : - QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::EditAddressDialog), - mapper(nullptr), - mode(_mode), - model(nullptr) + +EditAddressDialog::EditAddressDialog(Mode _mode, QWidget* parent) + : QDialog(parent, GUIUtil::dialog_flags), + ui(new Ui::EditAddressDialog), + mode(_mode) { ui->setupUi(this); diff --git a/src/qt/editaddressdialog.h b/src/qt/editaddressdialog.h index f7ad80bb2df1..7bfadcfbcc80 100644 --- a/src/qt/editaddressdialog.h +++ b/src/qt/editaddressdialog.h @@ -49,9 +49,9 @@ public Q_SLOTS: QString getDuplicateAddressWarning() const; Ui::EditAddressDialog *ui; - QDataWidgetMapper *mapper; + QDataWidgetMapper* mapper{nullptr}; Mode mode; - AddressTableModel *model; + AddressTableModel* model{nullptr}; QString address; }; diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp index e507e922ecaf..5e0da67467f5 100644 --- a/src/qt/intro.cpp +++ b/src/qt/intro.cpp @@ -123,8 +123,6 @@ int GetPruneTargetGB() Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_size_gb) : QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::Intro), - thread(nullptr), - signalled(false), m_blockchain_size_gb(blockchain_size_gb), m_chain_state_size_gb(chain_state_size_gb), m_prune_target_gb{GetPruneTargetGB()} diff --git a/src/qt/intro.h b/src/qt/intro.h index c01d005ae243..7b34c73b025b 100644 --- a/src/qt/intro.h +++ b/src/qt/intro.h @@ -65,9 +65,9 @@ private Q_SLOTS: private: Ui::Intro *ui; bool m_prune_checkbox_is_default{true}; - QThread *thread; + QThread* thread{nullptr}; QMutex mutex; - bool signalled; + bool signalled{false}; QString pathToCheck; const int64_t m_blockchain_size_gb; const int64_t m_chain_state_size_gb; diff --git a/src/qt/masternodelist.h b/src/qt/masternodelist.h index 097be4c3ac61..6d79daaa3eb8 100644 --- a/src/qt/masternodelist.h +++ b/src/qt/masternodelist.h @@ -40,7 +40,7 @@ class MasternodeList : public QWidget Q_OBJECT public: - explicit MasternodeList(QWidget* parent = 0); + explicit MasternodeList(QWidget* parent = nullptr); ~MasternodeList(); enum { diff --git a/src/qt/mnemonicverificationdialog.cpp b/src/qt/mnemonicverificationdialog.cpp index 365b8e6e5dc1..8dad20998f0c 100644 --- a/src/qt/mnemonicverificationdialog.cpp +++ b/src/qt/mnemonicverificationdialog.cpp @@ -27,7 +27,6 @@ MnemonicVerificationDialog::MnemonicVerificationDialog(const SecureString& mnemo QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::MnemonicVerificationDialog), m_mnemonic(mnemonic), - m_mnemonic_revealed(false), m_view_only(viewOnly) { ui->setupUi(this); diff --git a/src/qt/mnemonicverificationdialog.h b/src/qt/mnemonicverificationdialog.h index 309912201c15..5d1b706d6982 100644 --- a/src/qt/mnemonicverificationdialog.h +++ b/src/qt/mnemonicverificationdialog.h @@ -50,7 +50,7 @@ private Q_SLOTS: SecureString m_mnemonic; std::vector m_words; QList m_selected_positions; - bool m_mnemonic_revealed; + bool m_mnemonic_revealed{false}; bool m_has_ever_revealed{false}; bool m_view_only{false}; class QGridLayout* m_gridLayout{nullptr}; diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp index 8467491ff2a9..ed558f836703 100644 --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -12,14 +12,10 @@ #include #include -ModalOverlay::ModalOverlay(bool enable_wallet, QWidget *parent) : -QWidget(parent), -ui(new Ui::ModalOverlay), -bestHeaderHeight(0), -bestHeaderDate(QDateTime()), -layerIsVisible(false), -userClosed(false), -foreverHidden(false) +ModalOverlay::ModalOverlay(bool enable_wallet, QWidget* parent) + : QWidget(parent), + ui(new Ui::ModalOverlay), + bestHeaderDate(QDateTime()) { ui->setupUi(this); diff --git a/src/qt/modaloverlay.h b/src/qt/modaloverlay.h index 8b2403c8b15a..aed94f140cc8 100644 --- a/src/qt/modaloverlay.h +++ b/src/qt/modaloverlay.h @@ -43,12 +43,12 @@ public Q_SLOTS: private: Ui::ModalOverlay *ui; - int bestHeaderHeight; //best known height (based on the headers) + int bestHeaderHeight{0}; // best known height (based on the headers) QDateTime bestHeaderDate; QVector > blockProcessTime; - bool layerIsVisible; - bool userClosed; - bool foreverHidden; + bool layerIsVisible{false}; + bool userClosed{false}; + bool foreverHidden{false}; QPropertyAnimation m_animation; void UpdateHeaderSyncLabel(); }; diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp index e9f666b506cc..211c5cf5f227 100644 --- a/src/qt/notificator.cpp +++ b/src/qt/notificator.cpp @@ -31,11 +31,7 @@ Notificator::Notificator(const QString &_programName, QSystemTrayIcon *_trayIcon QObject(_parent), parent(_parent), programName(_programName), - mode(None), trayIcon(_trayIcon) -#ifdef USE_DBUS - ,interface(nullptr) -#endif { if(_trayIcon && _trayIcon->supportsMessages()) { diff --git a/src/qt/notificator.h b/src/qt/notificator.h index 97880469453b..c388159aca13 100644 --- a/src/qt/notificator.h +++ b/src/qt/notificator.h @@ -61,10 +61,10 @@ public Q_SLOTS: UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */ }; QString programName; - Mode mode; + Mode mode{None}; QSystemTrayIcon *trayIcon; #ifdef USE_DBUS - QDBusInterface *interface; + QDBusInterface* interface{nullptr}; void notifyDBus(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); #endif diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 034ae4f908ef..5e9d38f5a892 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -39,13 +39,10 @@ #include #include -OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : - QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::OptionsDialog), - model(nullptr), - mapper(nullptr), - pageButtons(nullptr), - m_enable_wallet(enableWallet) +OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) + : QDialog(parent, GUIUtil::dialog_flags), + ui(new Ui::OptionsDialog), + m_enable_wallet(enableWallet) { ui->setupUi(this); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 655d7ed6f6f2..13eb556f7c79 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -89,9 +89,9 @@ private Q_SLOTS: private: Ui::OptionsDialog *ui; ClientModel* m_client_model{nullptr}; - OptionsModel *model; - QDataWidgetMapper *mapper; - QButtonGroup* pageButtons; + OptionsModel* model{nullptr}; + QDataWidgetMapper* mapper{nullptr}; + QButtonGroup* pageButtons{nullptr}; QString previousTheme; AppearanceWidget* appearance; bool fCoinJoinEnabledPrev{false}; diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 8ed12617a19f..005893e79298 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -141,11 +141,7 @@ class TxViewDelegate : public QAbstractItemDelegate OverviewPage::OverviewPage(QWidget* parent) : QWidget(parent), - timer(nullptr), ui(new Ui::OverviewPage), - clientModel(nullptr), - walletModel(nullptr), - cachedNumISLocks(-1), txdelegate(new TxViewDelegate(this)) { ui->setupUi(this); diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index 8c507e073e2a..7bbfae77c35b 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -49,15 +49,15 @@ public Q_SLOTS: void outOfSyncWarningClicked(); private: - QTimer *timer; + QTimer* timer{nullptr}; Ui::OverviewPage *ui; - ClientModel *clientModel; - WalletModel *walletModel; + ClientModel* clientModel{nullptr}; + WalletModel* walletModel{nullptr}; interfaces::WalletBalances m_balances; bool m_privacy{false}; BitcoinUnit m_display_bitcoin_unit; bool fShowAdvancedCJUI; - int cachedNumISLocks; + int cachedNumISLocks{-1}; TxViewDelegate *txdelegate; std::unique_ptr filter; diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 6adf7fe4cc9b..a14ffd2909b0 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -125,11 +125,8 @@ bool PaymentServer::ipcSendCommandLine() return fResult; } -PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) : - QObject(parent), - saveURIs(true), - uriServer(nullptr), - optionsModel(nullptr) +PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) + : QObject(parent) { // Install global event filter to catch QFileOpenEvents // on Mac: sent when you click dash: links diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 545007ae7b97..ca9bb8954f75 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -101,9 +101,9 @@ private Q_SLOTS: bool eventFilter(QObject *object, QEvent *event) override; private: - bool saveURIs; // true during startup - QLocalServer* uriServer; - OptionsModel *optionsModel; + bool saveURIs{true}; // true during startup + QLocalServer* uriServer{nullptr}; + OptionsModel* optionsModel{nullptr}; }; #endif // BITCOIN_QT_PAYMENTSERVER_H diff --git a/src/qt/peertablemodel.cpp b/src/qt/peertablemodel.cpp index 370f40e9931e..550cc2faaa54 100644 --- a/src/qt/peertablemodel.cpp +++ b/src/qt/peertablemodel.cpp @@ -13,10 +13,9 @@ #include -PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) : - QAbstractTableModel(parent), - m_node(node), - timer(nullptr) +PeerTableModel::PeerTableModel(interfaces::Node& node, QObject* parent) + : QAbstractTableModel(parent), + m_node(node) { // set up timer for auto refresh timer = new QTimer(this); diff --git a/src/qt/peertablemodel.h b/src/qt/peertablemodel.h index e2515de7754f..9cbdad4374e2 100644 --- a/src/qt/peertablemodel.h +++ b/src/qt/peertablemodel.h @@ -110,7 +110,7 @@ public Q_SLOTS: /*: Title of Peers Table column which contains the peer's User Agent string. */ tr("User Agent")}; - QTimer *timer; + QTimer* timer{nullptr}; }; #endif // BITCOIN_QT_PEERTABLEMODEL_H diff --git a/src/qt/qrdialog.h b/src/qt/qrdialog.h index 681925377d5e..88ddaf5b1808 100644 --- a/src/qt/qrdialog.h +++ b/src/qt/qrdialog.h @@ -22,7 +22,7 @@ class QRDialog : public QDialog Q_OBJECT public: - explicit QRDialog(QWidget *parent = 0); + explicit QRDialog(QWidget* parent = nullptr); ~QRDialog(); void setInfo(QString strWindowtitle, QString strQRCode, QString strTextInfo, QString strQRCodeTitle); diff --git a/src/qt/qrimagewidget.cpp b/src/qt/qrimagewidget.cpp index 967838dda79f..3d937bf7f680 100644 --- a/src/qt/qrimagewidget.cpp +++ b/src/qt/qrimagewidget.cpp @@ -23,8 +23,8 @@ #include #endif -QRImageWidget::QRImageWidget(QWidget *parent): - QLabel(parent), contextMenu(nullptr) +QRImageWidget::QRImageWidget(QWidget* parent) + : QLabel(parent) { contextMenu = new QMenu(this); contextMenu->addAction(tr("&Save Image…"), this, &QRImageWidget::saveImage); diff --git a/src/qt/qrimagewidget.h b/src/qt/qrimagewidget.h index 776a920cc1cf..48c5a135ba1e 100644 --- a/src/qt/qrimagewidget.h +++ b/src/qt/qrimagewidget.h @@ -40,7 +40,7 @@ public Q_SLOTS: virtual void contextMenuEvent(QContextMenuEvent *event) override; private: - QMenu *contextMenu; + QMenu* contextMenu{nullptr}; }; #endif // BITCOIN_QT_QRIMAGEWIDGET_H diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp index e66e8a5d328d..3ad2139ad3dc 100644 --- a/src/qt/qvalidatedlineedit.cpp +++ b/src/qt/qvalidatedlineedit.cpp @@ -6,10 +6,8 @@ #include -QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : - QLineEdit(parent), - valid(true), - checkValidator(nullptr) +QValidatedLineEdit::QValidatedLineEdit(QWidget* parent) + : QLineEdit(parent) { connect(this, &QValidatedLineEdit::textChanged, this, &QValidatedLineEdit::markValid); } diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h index 12d35aa2645c..b26e2020c534 100644 --- a/src/qt/qvalidatedlineedit.h +++ b/src/qt/qvalidatedlineedit.h @@ -25,8 +25,8 @@ class QValidatedLineEdit : public QLineEdit void focusOutEvent(QFocusEvent *evt) override; private: - bool valid; - const QValidator *checkValidator; + bool valid{true}; + const QValidator* checkValidator{nullptr}; public Q_SLOTS: void setText(const QString&); diff --git a/src/qt/qvaluecombobox.cpp b/src/qt/qvaluecombobox.cpp index f94486a2f38f..c163ba56dca4 100644 --- a/src/qt/qvaluecombobox.cpp +++ b/src/qt/qvaluecombobox.cpp @@ -4,8 +4,8 @@ #include -QValueComboBox::QValueComboBox(QWidget *parent) : - QComboBox(parent), role(Qt::UserRole) +QValueComboBox::QValueComboBox(QWidget* parent) + : QComboBox(parent) { connect(this, qOverload(&QComboBox::currentIndexChanged), this, &QValueComboBox::handleSelectionChanged); } diff --git a/src/qt/qvaluecombobox.h b/src/qt/qvaluecombobox.h index bde9c0d1a602..14379dd612b7 100644 --- a/src/qt/qvaluecombobox.h +++ b/src/qt/qvaluecombobox.h @@ -28,7 +28,7 @@ class QValueComboBox : public QComboBox void valueChanged(); private: - int role; + int role{Qt::UserRole}; private Q_SLOTS: void handleSelectionChanged(int idx); diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index ebb0798ed461..0e030606fd37 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -18,8 +18,7 @@ ReceiveCoinsDialog::ReceiveCoinsDialog(QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::ReceiveCoinsDialog), - model(nullptr) + ui(new Ui::ReceiveCoinsDialog) { ui->setupUi(this); diff --git a/src/qt/receivecoinsdialog.h b/src/qt/receivecoinsdialog.h index 697c5f72b930..d0f29c86ffd4 100644 --- a/src/qt/receivecoinsdialog.h +++ b/src/qt/receivecoinsdialog.h @@ -47,7 +47,7 @@ public Q_SLOTS: private: Ui::ReceiveCoinsDialog *ui; - WalletModel *model; + WalletModel* model{nullptr}; QMenu *contextMenu; QAction* copyLabelAction; QAction* copyMessageAction; diff --git a/src/qt/receiverequestdialog.cpp b/src/qt/receiverequestdialog.cpp index 84021eb2a9ba..dee027526167 100644 --- a/src/qt/receiverequestdialog.cpp +++ b/src/qt/receiverequestdialog.cpp @@ -19,10 +19,9 @@ #include /* for USE_QRCODE */ #endif -ReceiveRequestDialog::ReceiveRequestDialog(QWidget *parent) : - QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::ReceiveRequestDialog), - model(nullptr) +ReceiveRequestDialog::ReceiveRequestDialog(QWidget* parent) + : QDialog(parent, GUIUtil::dialog_flags), + ui(new Ui::ReceiveRequestDialog) { ui->setupUi(this); diff --git a/src/qt/receiverequestdialog.h b/src/qt/receiverequestdialog.h index c861680761e3..d64fee366360 100644 --- a/src/qt/receiverequestdialog.h +++ b/src/qt/receiverequestdialog.h @@ -33,7 +33,7 @@ private Q_SLOTS: private: Ui::ReceiveRequestDialog *ui; - WalletModel *model; + WalletModel* model{nullptr}; SendCoinsRecipient info; }; diff --git a/src/qt/recentrequeststablemodel.h b/src/qt/recentrequeststablemodel.h index 1cc8c2b2b506..0a38b57de024 100644 --- a/src/qt/recentrequeststablemodel.h +++ b/src/qt/recentrequeststablemodel.h @@ -18,11 +18,11 @@ class WalletModel; class RecentRequestEntry { public: - RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION), id(0) { } + RecentRequestEntry() : nVersion(RecentRequestEntry::CURRENT_VERSION) {} static const int CURRENT_VERSION = 1; int nVersion; - int64_t id; + int64_t id{0}; QDateTime date; SendCoinsRecipient recipient; diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index b5e6e81ffdde..2bf5ca1d603f 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -63,11 +63,7 @@ int getIndexForConfTarget(int target) { SendCoinsDialog::SendCoinsDialog(bool _fCoinJoin, QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags), ui(new Ui::SendCoinsDialog), - clientModel(nullptr), - model(nullptr), - m_coin_control(new CCoinControl), - fNewRecipientAllowed(true), - fFeeMinimized(true) + m_coin_control(new CCoinControl) { ui->setupUi(this); diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 22aa578be639..d9d5857a9dcb 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -63,13 +63,13 @@ public Q_SLOTS: private: Ui::SendCoinsDialog *ui; - ClientModel *clientModel; - WalletModel *model; + ClientModel* clientModel{nullptr}; + WalletModel* model{nullptr}; std::unique_ptr m_coin_control; std::unique_ptr m_current_transaction; - bool fNewRecipientAllowed; + bool fNewRecipientAllowed{true}; bool send(const QList& recipients, QString& question_string, QString& informative_text, QString& detailed_text); - bool fFeeMinimized; + bool fFeeMinimized{true}; bool fKeepChangeAddress; // Process WalletModel::SendCoinsReturn and generate a pair consisting diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index fb447acc362d..0fe12ebad5dc 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -22,8 +22,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget* parent) : QWidget(parent), - ui(new Ui::SendCoinsEntry), - model(nullptr) + ui(new Ui::SendCoinsEntry) { ui->setupUi(this); diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h index 87b931e68e75..1cbd0637e8f5 100644 --- a/src/qt/sendcoinsentry.h +++ b/src/qt/sendcoinsentry.h @@ -72,7 +72,7 @@ private Q_SLOTS: private: SendCoinsRecipient recipient; Ui::SendCoinsEntry *ui; - WalletModel *model; + WalletModel* model{nullptr}; /** Set required icons for buttons inside the dialog */ void setButtonIcons(); diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index 058c6f454862..c66d8478a5c8 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -23,9 +23,7 @@ SignVerifyMessageDialog::SignVerifyMessageDialog(QWidget* parent) : QDialog(parent, GUIUtil::dialog_flags), - ui(new Ui::SignVerifyMessageDialog), - model(nullptr), - pageButtons(nullptr) + ui(new Ui::SignVerifyMessageDialog) { ui->setupUi(this); diff --git a/src/qt/signverifymessagedialog.h b/src/qt/signverifymessagedialog.h index 6ee22dde157f..04bb39e0c915 100644 --- a/src/qt/signverifymessagedialog.h +++ b/src/qt/signverifymessagedialog.h @@ -37,8 +37,8 @@ class SignVerifyMessageDialog : public QDialog private: Ui::SignVerifyMessageDialog *ui; - WalletModel *model; - QButtonGroup* pageButtons; + WalletModel* model{nullptr}; + QButtonGroup* pageButtons{nullptr}; void showEvent(QShowEvent* event) override; diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 3aa8454664b1..f9b32dc58e01 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -29,8 +29,9 @@ #include #include -SplashScreen::SplashScreen(const NetworkStyle *networkStyle) : - QWidget(), curAlignment(0) + +SplashScreen::SplashScreen(const NetworkStyle* networkStyle) + : QWidget() { // transparent background diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index af619b37ac69..d326bceea920 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -57,7 +57,7 @@ public Q_SLOTS: QPixmap pixmap; QString curMessage; QColor curColor; - int curAlignment; + int curAlignment{0}; interfaces::Node* m_node = nullptr; bool m_shutdown = false; diff --git a/src/qt/trafficgraphdata.cpp b/src/qt/trafficgraphdata.cpp index 7561336d6a10..2de10a90127e 100644 --- a/src/qt/trafficgraphdata.cpp +++ b/src/qt/trafficgraphdata.cpp @@ -23,10 +23,7 @@ const int TrafficGraphData::SMALLEST_SAMPLE_PERIOD = TrafficGraphData::RangeMinutes[TrafficGraphData::Range_5m] * 60 * 1000 / TrafficGraphData::DESIRED_DATA_SAMPLES; TrafficGraphData::TrafficGraphData(GraphRange range) - :currentGraphRange(range), - currentSampleCounter(0), - nLastBytesIn(0), - nLastBytesOut(0) + :currentGraphRange(range) { } diff --git a/src/qt/trafficgraphdata.h b/src/qt/trafficgraphdata.h index 1847bd5b4def..a9e1ccfadfd1 100644 --- a/src/qt/trafficgraphdata.h +++ b/src/qt/trafficgraphdata.h @@ -75,10 +75,10 @@ class TrafficGraphData SampleQueueMap sampleStash; GraphRange currentGraphRange; - int currentSampleCounter; + int currentSampleCounter{0}; - quint64 nLastBytesIn; - quint64 nLastBytesOut; + quint64 nLastBytesIn{0}; + quint64 nLastBytesOut{0}; void update(GraphRange range, const TrafficSample &trafficSample); diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index fa3af19bf872..265bb669ed57 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -18,15 +18,9 @@ #define XMARGIN 10 #define YMARGIN 10 -#define DEFAULT_SAMPLE_HEIGHT 1.1f - -TrafficGraphWidget::TrafficGraphWidget(QWidget *parent) : - QWidget(parent), - timer(nullptr), - fMax(DEFAULT_SAMPLE_HEIGHT), - nMins(0), - clientModel(nullptr), - trafficGraphData(TrafficGraphData::Range_30m) +TrafficGraphWidget::TrafficGraphWidget(QWidget* parent) + : QWidget(parent), + trafficGraphData(TrafficGraphData::Range_30m) { timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &TrafficGraphWidget::updateRates); @@ -234,7 +228,7 @@ void TrafficGraphWidget::updateRates() bool updated = trafficGraphData.update(clientModel->node().getTotalBytesRecv(),clientModel->node().getTotalBytesSent()); if (updated){ - float tmax = DEFAULT_SAMPLE_HEIGHT; + float tmax = default_sample_height; for (const TrafficSample& sample : trafficGraphData.getCurrentRangeQueueWithAverageBandwidth()) { if(sample.in > tmax) tmax = sample.in; if(sample.out > tmax) tmax = sample.out; @@ -253,7 +247,7 @@ void TrafficGraphWidget::setGraphRangeMins(int value) void TrafficGraphWidget::clear() { trafficGraphData.clear(); - fMax = DEFAULT_SAMPLE_HEIGHT; + fMax = default_sample_height; if(clientModel) { trafficGraphData.setLastBytes(clientModel->node().getTotalBytesRecv(), clientModel->node().getTotalBytesSent()); } diff --git a/src/qt/trafficgraphwidget.h b/src/qt/trafficgraphwidget.h index e3e57620f761..6fc60c0d556c 100644 --- a/src/qt/trafficgraphwidget.h +++ b/src/qt/trafficgraphwidget.h @@ -34,13 +34,14 @@ public Q_SLOTS: void clear(); private: + static constexpr float default_sample_height{1.1f}; typedef std::function SampleChooser; void paintPath(QPainterPath &path, const TrafficGraphData::SampleQueue &queue, SampleChooser chooser); - QTimer *timer; - float fMax; - int nMins; - ClientModel *clientModel; + QTimer* timer{nullptr}; + float fMax{default_sample_height}; + int nMins{0}; + ClientModel* clientModel{nullptr}; TrafficGraphData trafficGraphData; }; diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index f14f0a71628f..12758886ad63 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -11,14 +11,10 @@ #include #include -TransactionFilterProxy::TransactionFilterProxy(QObject *parent) : - QSortFilterProxyModel(parent), - m_search_string(), - typeFilter(COMMON_TYPES), - watchOnlyFilter(WatchOnlyFilter_All), - minAmount(0), - limitRows(-1), - showInactive(true) +TransactionFilterProxy::TransactionFilterProxy(QObject* parent) + : QSortFilterProxyModel(parent), + m_search_string(), + typeFilter(COMMON_TYPES) { } diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 71d6f031a364..1801d27bcae8 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -60,10 +60,10 @@ class TransactionFilterProxy : public QSortFilterProxyModel std::optional dateTo; QString m_search_string; quint32 typeFilter; - WatchOnlyFilter watchOnlyFilter; - CAmount minAmount; - int limitRows; - bool showInactive; + WatchOnlyFilter watchOnlyFilter{WatchOnlyFilter_All}; + CAmount minAmount{0}; + int limitRows{-1}; + bool showInactive{true}; }; #endif // BITCOIN_QT_TRANSACTIONFILTERPROXY_H diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 296a9e88622d..e676f04a2237 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -268,9 +268,7 @@ class TransactionTablePriv TransactionTableModel::TransactionTableModel(WalletModel *parent): QAbstractTableModel(parent), walletModel(parent), - priv(new TransactionTablePriv(this)), - fProcessingQueuedTransactions(false), - cachedChainLockHeight(-1) + priv(new TransactionTablePriv(this)) { subscribeToCoreSignals(); diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 630fec039f73..c1fb9a447585 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -93,8 +93,8 @@ class TransactionTableModel : public QAbstractTableModel std::unique_ptr m_handler_show_progress; QStringList columns; TransactionTablePriv *priv; - bool fProcessingQueuedTransactions; - int cachedChainLockHeight; + bool fProcessingQueuedTransactions{false}; + int cachedChainLockHeight{-1}; void subscribeToCoreSignals(); void unsubscribeFromCoreSignals(); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 0a9a196cfc04..d6cddd67dbae 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -50,13 +50,7 @@ WalletModel::WalletModel(std::unique_ptr wallet, ClientModel m_client_model(&client_model), m_node(client_model.node()), optionsModel(client_model.getOptionsModel()), - addressTableModel(nullptr), - transactionTableModel(nullptr), - recentRequestsTableModel(nullptr), - cachedEncryptionStatus(Unencrypted), - timer(new QTimer(this)), - cachedNumISLocks(0), - cachedCoinJoinRounds(0) + timer(new QTimer(this)) { fHaveWatchOnly = m_wallet->haveWatchOnly(); addressTableModel = new AddressTableModel(this); diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index b33e74a43ada..3124f86c110a 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -183,16 +183,16 @@ class WalletModel : public QObject // (transaction fee, for example) OptionsModel *optionsModel; - AddressTableModel *addressTableModel; - TransactionTableModel *transactionTableModel; - RecentRequestsTableModel *recentRequestsTableModel; + AddressTableModel* addressTableModel{nullptr}; + TransactionTableModel* transactionTableModel{nullptr}; + RecentRequestsTableModel* recentRequestsTableModel{nullptr}; // Cache some values to be able to detect changes interfaces::WalletBalances m_cached_balances; - EncryptionStatus cachedEncryptionStatus; + EncryptionStatus cachedEncryptionStatus{Unencrypted}; QTimer* timer; - int cachedNumISLocks; - int cachedCoinJoinRounds; + int cachedNumISLocks{0}; + int cachedCoinJoinRounds{0}; // Block hash denoting when the last balance update was done. uint256 m_cached_last_update_tip{}; diff --git a/src/qt/walletmodeltransaction.cpp b/src/qt/walletmodeltransaction.cpp index c3dc38fa27c9..496cc7f10ff6 100644 --- a/src/qt/walletmodeltransaction.cpp +++ b/src/qt/walletmodeltransaction.cpp @@ -10,9 +10,8 @@ #include -WalletModelTransaction::WalletModelTransaction(const QList &_recipients) : - recipients(_recipients), - fee(0) +WalletModelTransaction::WalletModelTransaction(const QList& _recipients) + : recipients(_recipients) { } diff --git a/src/qt/walletmodeltransaction.h b/src/qt/walletmodeltransaction.h index 67effb8e2908..61e1fc76ee41 100644 --- a/src/qt/walletmodeltransaction.h +++ b/src/qt/walletmodeltransaction.h @@ -41,7 +41,7 @@ class WalletModelTransaction private: QList recipients; CTransactionRef wtx; - CAmount fee; + CAmount fee{0}; }; #endif // BITCOIN_QT_WALLETMODELTRANSACTION_H diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index e74ecd52ec44..684ab37e8bf4 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -37,7 +37,6 @@ WalletView::WalletView(WalletModel* wallet_model, QWidget* parent) : QStackedWidget(parent), - clientModel(nullptr), walletModel(wallet_model) { assert(walletModel); diff --git a/src/qt/walletview.h b/src/qt/walletview.h index 328b42821d06..4a527fbfb9bc 100644 --- a/src/qt/walletview.h +++ b/src/qt/walletview.h @@ -52,7 +52,7 @@ class WalletView : public QStackedWidget void showOutOfSyncWarning(bool fShow); private: - ClientModel *clientModel; + ClientModel* clientModel{nullptr}; //! //! The wallet model represents a bitcoin wallet, and offers access to diff --git a/src/rpc/blockchain.h b/src/rpc/blockchain.h index 0ef7c2bd30e6..f84cb6794fbe 100644 --- a/src/rpc/blockchain.h +++ b/src/rpc/blockchain.h @@ -17,7 +17,7 @@ #include #include -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class CBlock; class CBlockIndex; diff --git a/src/rpc/index_util.h b/src/rpc/index_util.h index 2624ae4578bd..1a351f8f37dc 100644 --- a/src/rpc/index_util.h +++ b/src/rpc/index_util.h @@ -22,7 +22,7 @@ class uint256; enum class AddressType : uint8_t; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) //! throws JSONRPCError if address index is unavailable bool GetAddressIndex(CBlockTreeDB& block_tree_db, const uint160& addressHash, const AddressType type, diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 9aae2d7e0c96..67d012ab2bcd 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -359,6 +359,7 @@ struct Sections { const auto indent = std::string(current_indent, ' '); const auto indent_next = std::string(current_indent + 2, ' '); const bool push_name{outer_type == OuterType::OBJ}; // Dictionary keys must have a name + const bool is_top_level_arg{outer_type == OuterType::NONE}; // True on the first recursion switch (arg.m_type) { case RPCArg::Type::STR_HEX: @@ -367,7 +368,7 @@ struct Sections { case RPCArg::Type::AMOUNT: case RPCArg::Type::RANGE: case RPCArg::Type::BOOL: { - if (outer_type == OuterType::NONE) return; // Nothing more to do for non-recursive types on first recursion + if (is_top_level_arg) return; // Nothing more to do for non-recursive types on first recursion auto left = indent; if (arg.m_type_str.size() != 0 && push_name) { left += "\"" + arg.GetName() + "\": " + arg.m_type_str.at(0); @@ -375,12 +376,12 @@ struct Sections { left += push_name ? arg.ToStringObj(/*oneline=*/false) : arg.ToString(/*oneline=*/false); } left += ","; - PushSection({left, arg.ToDescriptionString()}); + PushSection({left, arg.ToDescriptionString(/*is_named_arg=*/push_name)}); break; } case RPCArg::Type::OBJ: case RPCArg::Type::OBJ_USER_KEYS: { - const auto right = outer_type == OuterType::NONE ? "" : arg.ToDescriptionString(); + const auto right = is_top_level_arg ? "" : arg.ToDescriptionString(/*is_named_arg=*/push_name); PushSection({indent + (push_name ? "\"" + arg.GetName() + "\": " : "") + "{", right}); for (const auto& arg_inner : arg.m_inner) { Push(arg_inner, current_indent + 2, OuterType::OBJ); @@ -388,20 +389,20 @@ struct Sections { if (arg.m_type != RPCArg::Type::OBJ) { PushSection({indent_next + "...", ""}); } - PushSection({indent + "}" + (outer_type != OuterType::NONE ? "," : ""), ""}); + PushSection({indent + "}" + (is_top_level_arg ? "" : ","), ""}); break; } case RPCArg::Type::ARR: { auto left = indent; left += push_name ? "\"" + arg.GetName() + "\": " : ""; left += "["; - const auto right = outer_type == OuterType::NONE ? "" : arg.ToDescriptionString(); + const auto right = is_top_level_arg ? "" : arg.ToDescriptionString(/*is_named_arg=*/push_name); PushSection({left, right}); for (const auto& arg_inner : arg.m_inner) { Push(arg_inner, current_indent + 2, OuterType::ARR); } PushSection({indent_next + "...", ""}); - PushSection({indent + "]" + (outer_type != OuterType::NONE ? "," : ""), ""}); + PushSection({indent + "]" + (is_top_level_arg ? "" : ","), ""}); break; } } // no default case, so the compiler can warn about missing cases @@ -595,7 +596,7 @@ std::string RPCHelpMan::ToString() const if (i == 0) ret += "\nArguments:\n"; // Push named argument name and description - sections.m_sections.emplace_back(::ToString(i + 1) + ". " + arg.GetFirstName(), arg.ToDescriptionString()); + sections.m_sections.emplace_back(::ToString(i + 1) + ". " + arg.GetFirstName(), arg.ToDescriptionString(/*is_named_arg=*/true)); sections.m_max_pad = std::max(sections.m_max_pad, sections.m_sections.back().m_left.size()); // Recursively push nested args @@ -651,7 +652,7 @@ bool RPCArg::IsOptional() const } } -std::string RPCArg::ToDescriptionString() const +std::string RPCArg::ToDescriptionString(bool is_named_arg) const { std::string ret; ret += "("; @@ -697,14 +698,12 @@ std::string RPCArg::ToDescriptionString() const ret += ", optional, default=" + std::get(m_fallback).write(); } else { switch (std::get(m_fallback)) { + case RPCArg::Optional::OMITTED_NAMED_ARG: // Deprecated alias for OMITTED, can be removed case RPCArg::Optional::OMITTED: { + if (is_named_arg) ret += ", optional"; // Default value is "null" in dicts. Otherwise, // nothing to do. Element is treated as if not present and has no default value break; } - case RPCArg::Optional::OMITTED_NAMED_ARG: { - ret += ", optional"; // Default value is "null" - break; - } case RPCArg::Optional::NO: { ret += ", required"; break; diff --git a/src/rpc/util.h b/src/rpc/util.h index fe12b4cbaf4f..6a62ca00e3e2 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -157,21 +157,25 @@ struct RPCArg { /** Required arg */ NO, /** + * The arg is optional for one of two reasons: + * * Optional arg that is a named argument and has a default value of - * `null`. When possible, the default value should be specified. - */ - OMITTED_NAMED_ARG, - /** + * `null`. + * * Optional argument with default value omitted because they are - * implicitly clear. That is, elements in an array or object may not + * implicitly clear. That is, elements in an array may not * exist by default. * When possible, the default value should be specified. */ OMITTED, + OMITTED_NAMED_ARG, // Deprecated alias for OMITTED, can be removed }; + /** Hint for default value */ using DefaultHint = std::string; + /** Default constant value */ using Default = UniValue; - using Fallback = std::variant; + using Fallback = std::variant; + const std::string m_names; //!< The name of the arg (can be empty for inner args, can contain multiple aliases separated by | for named request arguments) const Type m_type; const bool m_hidden; @@ -182,13 +186,13 @@ struct RPCArg { const std::vector m_type_str; //!< Should be empty unless it is supposed to override the auto-generated type strings. Vector length is either 0 or 2, m_type_str.at(0) will override the type of the value in a key-value pair, m_type_str.at(1) will override the type in the argument description. RPCArg( - const std::string name, - const Type type, - const Fallback fallback, - const std::string description, - const std::string oneline_description = "", - const std::vector type_str = {}, - const bool hidden = false) + std::string name, + Type type, + Fallback fallback, + std::string description, + std::string oneline_description = "", + std::vector type_str = {}, + bool hidden = false) : m_names{std::move(name)}, m_type{std::move(type)}, m_hidden{hidden}, @@ -201,13 +205,13 @@ struct RPCArg { } RPCArg( - const std::string name, - const Type type, - const Fallback fallback, - const std::string description, - const std::vector inner, - const std::string oneline_description = "", - const std::vector type_str = {}) + std::string name, + Type type, + Fallback fallback, + std::string description, + std::vector inner, + std::string oneline_description = "", + std::vector type_str = {}) : m_names{std::move(name)}, m_type{std::move(type)}, m_hidden{false}, @@ -242,7 +246,7 @@ struct RPCArg { * Return the description string, including the argument type and whether * the argument is required. */ - std::string ToDescriptionString() const; + std::string ToDescriptionString(bool is_named_arg) const; }; struct RPCResult { @@ -270,12 +274,12 @@ struct RPCResult { const std::string m_cond; RPCResult( - const std::string cond, - const Type type, - const std::string m_key_name, - const bool optional, - const std::string description, - const std::vector inner = {}) + std::string cond, + Type type, + std::string m_key_name, + bool optional, + std::string description, + std::vector inner = {}) : m_type{std::move(type)}, m_key_name{std::move(m_key_name)}, m_inner{std::move(inner)}, @@ -288,19 +292,19 @@ struct RPCResult { } RPCResult( - const std::string cond, - const Type type, - const std::string m_key_name, - const std::string description, - const std::vector inner = {}) - : RPCResult{cond, type, m_key_name, false, description, inner} {} + std::string cond, + Type type, + std::string m_key_name, + std::string description, + std::vector inner = {}) + : RPCResult{std::move(cond), type, std::move(m_key_name), /*optional=*/false, std::move(description), std::move(inner)} {} RPCResult( - const Type type, - const std::string m_key_name, - const bool optional, - const std::string description, - const std::vector inner = {}) + Type type, + std::string m_key_name, + bool optional, + std::string description, + std::vector inner = {}) : m_type{std::move(type)}, m_key_name{std::move(m_key_name)}, m_inner{std::move(inner)}, @@ -312,10 +316,10 @@ struct RPCResult { } RPCResult( - const Type type, - const std::string m_key_name, - const std::string description, - const std::vector inner = {}) + Type type, + std::string m_key_name, + std::string description, + std::vector inner = {}) : RPCResult{type, m_key_name, false, description, inner} {} /** Append the sections of the result. */ diff --git a/src/serialize.h b/src/serialize.h index d0ac4e8f8917..027f9d87c434 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1347,11 +1347,11 @@ struct CSerActionUnserialize class CSizeComputer { protected: - size_t nSize; + size_t nSize{0}; const int nVersion; public: - explicit CSizeComputer(int nVersionIn) : nSize(0), nVersion(nVersionIn) {} + explicit CSizeComputer(int nVersionIn) : nVersion(nVersionIn) {} void write(Span src) { diff --git a/src/span.h b/src/span.h index 6e6b58dbaa0b..fd9cdbc9eec5 100644 --- a/src/span.h +++ b/src/span.h @@ -96,7 +96,7 @@ template class Span { C* m_data; - std::size_t m_size; + std::size_t m_size{0}; template struct is_Span_int : public std::false_type {}; @@ -107,7 +107,7 @@ class Span public: - constexpr Span() noexcept : m_data(nullptr), m_size(0) {} + constexpr Span() noexcept : m_data(nullptr) {} /** Construct a span from a begin pointer and a size. * diff --git a/src/stats/client.h b/src/stats/client.h index dad20111d9c7..a534fbea9b25 100644 --- a/src/stats/client.h +++ b/src/stats/client.h @@ -17,11 +17,11 @@ class ArgsManager; /** Default host assumed to be running a Statsd server */ -static const std::string DEFAULT_STATSD_HOST{""}; +static const std::string DEFAULT_STATSD_HOST{}; /** Default prefix prepended to Statsd message keys */ -static const std::string DEFAULT_STATSD_PREFIX{""}; +static const std::string DEFAULT_STATSD_PREFIX{}; /** Default suffix appended to Statsd message keys */ -static const std::string DEFAULT_STATSD_SUFFIX{""}; +static const std::string DEFAULT_STATSD_SUFFIX{}; /** Default number of milliseconds between flushing a queue of messages */ static constexpr int DEFAULT_STATSD_DURATION{1000}; diff --git a/src/streams.h b/src/streams.h index 9790914f47cd..150c420c789b 100644 --- a/src/streams.h +++ b/src/streams.h @@ -624,8 +624,8 @@ class CBufferedFile const int nVersion; FILE *src; //!< source file - uint64_t nSrcPos; //!< how many bytes have been read from source - uint64_t m_read_pos; //!< how many bytes have been read from this + uint64_t nSrcPos{0}; //!< how many bytes have been read from source + uint64_t m_read_pos{0}; //!< how many bytes have been read from this uint64_t nReadLimit; //!< up to which position we're allowed to read uint64_t nRewind; //!< how many bytes we guarantee to rewind std::vector vchBuf; //!< the buffer @@ -671,7 +671,7 @@ class CBufferedFile public: CBufferedFile(FILE* fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) - : nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), m_read_pos(0), nReadLimit(std::numeric_limits::max()), nRewind(nRewindIn), vchBuf(nBufSize, std::byte{0}) + : nType(nTypeIn), nVersion(nVersionIn), nReadLimit(std::numeric_limits::max()), nRewind(nRewindIn), vchBuf(nBufSize, std::byte{0}) { if (nRewindIn >= nBufSize) throw std::ios_base::failure("Rewind limit must be less than buffer size"); diff --git a/src/support/allocators/mt_pooled_secure.h b/src/support/allocators/mt_pooled_secure.h index c97c22d36cf1..7f4576715db0 100644 --- a/src/support/allocators/mt_pooled_secure.h +++ b/src/support/allocators/mt_pooled_secure.h @@ -38,7 +38,7 @@ struct mt_pooled_secure_allocator : public std::allocator { } ~mt_pooled_secure_allocator() noexcept {} - T* allocate(std::size_t n, const void* hint = 0) + T* allocate(std::size_t n, const void* hint = nullptr) { size_t bucket = get_bucket(); std::lock_guard lock(pools[bucket]->mutex); diff --git a/src/support/allocators/pooled_secure.h b/src/support/allocators/pooled_secure.h index 3e8252a23065..f24707c31f0e 100644 --- a/src/support/allocators/pooled_secure.h +++ b/src/support/allocators/pooled_secure.h @@ -32,7 +32,7 @@ struct pooled_secure_allocator : public std::allocator { pool(nrequested_size, nnext_size, nmax_size){} ~pooled_secure_allocator() noexcept {} - T* allocate(std::size_t n, const void* hint = 0) + T* allocate(std::size_t n, const void* hint = nullptr) { size_t chunks = (n * sizeof(T) + pool.get_requested_size() - 1) / pool.get_requested_size(); return static_cast(pool.ordered_malloc(chunks)); diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 5682211630a3..6c3aaa9f04fa 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -281,8 +281,8 @@ size_t PosixLockedPageAllocator::GetLimit() /*******************************************************************************/ // Implementation: LockedPool -LockedPool::LockedPool(std::unique_ptr allocator_in, LockingFailed_Callback lf_cb_in): - allocator(std::move(allocator_in)), lf_cb(lf_cb_in), cumulative_bytes_locked(0) +LockedPool::LockedPool(std::unique_ptr allocator_in, LockingFailed_Callback lf_cb_in) + : allocator(std::move(allocator_in)), lf_cb(lf_cb_in) { } diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index 794e51cc6baa..81e0df513a33 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -198,7 +198,7 @@ class LockedPool std::list arenas; LockingFailed_Callback lf_cb; - size_t cumulative_bytes_locked; + size_t cumulative_bytes_locked{0}; /** Mutex protects access to this pool's data structures, including arenas. */ mutable std::mutex mutex; diff --git a/src/test/fuzz/miniscript.cpp b/src/test/fuzz/miniscript.cpp index 591cbc77118f..592ee2e560fb 100644 --- a/src/test/fuzz/miniscript.cpp +++ b/src/test/fuzz/miniscript.cpp @@ -104,7 +104,7 @@ struct ScriptParserContext { return key.data; } - const std::vector ToPKHBytes(const Key& key) const + std::vector ToPKHBytes(const Key& key) const { if (key.is_hash) return key.data; const auto h = Hash160(key.data); diff --git a/src/test/util/net.h b/src/test/util/net.h index a52a3ec753d1..fbe8b7d6e00a 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -133,7 +133,7 @@ constexpr auto ALL_NETWORKS = std::array{ class StaticContentsSock : public Sock { public: - explicit StaticContentsSock(const std::string& contents) : m_contents{contents}, m_consumed{0} + explicit StaticContentsSock(const std::string& contents) : m_contents{contents} { // Just a dummy number that is not INVALID_SOCKET. m_socket = INVALID_SOCKET - 1; @@ -224,7 +224,7 @@ class StaticContentsSock : public Sock private: const std::string m_contents; - mutable size_t m_consumed; + mutable size_t m_consumed{0}; }; std::vector GetRandomNodeEvictionCandidates(int n_candidates, FastRandomContext& random_context); diff --git a/src/tinyformat.h b/src/tinyformat.h index 3d128a98929c..d4cf07928679 100644 --- a/src/tinyformat.h +++ b/src/tinyformat.h @@ -508,9 +508,6 @@ class FormatArg { public: FormatArg() - : m_value(nullptr), - m_formatImpl(nullptr), - m_toIntImpl(nullptr) { } template @@ -549,10 +546,10 @@ class FormatArg return convertToInt::invoke(*static_cast(value)); } - const void* m_value; + const void* m_value{nullptr}; void (*m_formatImpl)(std::ostream& out, const char* fmtBegin, - const char* fmtEnd, int ntrunc, const void* value); - int (*m_toIntImpl)(const void* value); + const char* fmtEnd, int ntrunc, const void* value){nullptr}; + int (*m_toIntImpl)(const void* value){nullptr}; }; diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 8387f467a914..a3110a876ffd 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -63,8 +63,8 @@ static const uint16_t DEFAULT_TOR_SOCKS_PORT = 9050; /****** Low-level TorControlConnection ********/ -TorControlConnection::TorControlConnection(struct event_base *_base): - base(_base), b_conn(nullptr) +TorControlConnection::TorControlConnection(struct event_base* _base) + : base(_base) { } diff --git a/src/torcontrol.h b/src/torcontrol.h index a0603fb1d705..3b4fcb0b7ee3 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -87,7 +87,7 @@ class TorControlConnection /** Libevent event base */ struct event_base *base; /** Connection to control socket */ - struct bufferevent *b_conn; + struct bufferevent* b_conn{nullptr}; /** Message being received */ TorControlReply message; /** Response handlers */ diff --git a/src/txdb.h b/src/txdb.h index 493be625128f..886071586514 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -46,7 +46,7 @@ static const int64_t max_filter_index_cache = 1024; static const int64_t nMaxCoinsDBCache = 8; // Actually declared in validation.cpp; can't include because of circular dependency. -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) /** CCoinsView backed by the coin database (chainstate/) */ class CCoinsViewDB final : public CCoinsView diff --git a/src/txmempool.h b/src/txmempool.h index dec456a925c5..959d02b6860f 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -42,7 +42,7 @@ class CBlockIndex; class CChain; class CChainState; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) // Forward declaration for CBLSLazyPublicKey: template class CBLSLazyWrapper; diff --git a/src/univalue/include/univalue_utffilter.h b/src/univalue/include/univalue_utffilter.h index f688eaaa30f9..41d8e6bb05f7 100644 --- a/src/univalue/include/univalue_utffilter.h +++ b/src/univalue/include/univalue_utffilter.h @@ -13,8 +13,8 @@ class JSONUTF8StringFilter { public: - explicit JSONUTF8StringFilter(std::string &s): - str(s), is_valid(true), codepoint(0), state(0), surpair(0) + explicit JSONUTF8StringFilter(std::string& s) + : str(s) { } // Write single 8-bit char (may be part of UTF-8 sequence) @@ -79,10 +79,10 @@ class JSONUTF8StringFilter } private: std::string &str; - bool is_valid; + bool is_valid{true}; // Current UTF-8 decoding state - unsigned int codepoint; - int state; // Top bit to be filled in for next UTF-8 byte, or 0 + unsigned int codepoint{0}; + int state{0}; // Top bit to be filled in for next UTF-8 byte, or 0 // Keep track of the following state to handle the following section of // RFC4627: @@ -94,7 +94,7 @@ class JSONUTF8StringFilter // "\uD834\uDD1E". // // Two subsequent \u.... may have to be replaced with one actual codepoint. - unsigned int surpair; // First half of open UTF-16 surrogate pair, or 0 + unsigned int surpair{0}; // First half of open UTF-16 surrogate pair, or 0 void append_codepoint(unsigned int codepoint_) { diff --git a/src/util/hasher.cpp b/src/util/hasher.cpp index 69e2104bd877..92dc25ac4d16 100644 --- a/src/util/hasher.cpp +++ b/src/util/hasher.cpp @@ -9,7 +9,7 @@ #include -SaltedTxidHasher::SaltedTxidHasher() : k0(), k1() {} +SaltedTxidHasher::SaltedTxidHasher() : k0(GetRand()), k1(GetRand()) {} SaltedOutpointHasher::SaltedOutpointHasher(bool deterministic) : k0(deterministic ? 0x8e819f2607a18de6 : GetRand()), diff --git a/src/validation.h b/src/validation.h index 9301ad4c78fd..9a11c25cdb38 100644 --- a/src/validation.h +++ b/src/validation.h @@ -112,7 +112,7 @@ enum class SynchronizationState { POST_INIT }; -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) extern GlobalMutex g_best_block_mutex; extern std::condition_variable g_best_block_cv; /** Used to notify getblocktemplate RPC of new tips. */ diff --git a/src/validationinterface.h b/src/validationinterface.h index 563133d29cc4..80b9a5f22a70 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -12,7 +12,7 @@ #include #include -extern RecursiveMutex cs_main; +extern RecursiveMutex cs_main; // NOLINT(readability-redundant-declaration) class BlockValidationState; class CBlock; class CBlockIndex; diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index c5c3870fd6fa..38253d60c5d6 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -318,7 +318,7 @@ BerkeleyDatabase::~BerkeleyDatabase() } } -BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const bool read_only, bool fFlushOnCloseIn) : pdb(nullptr), activeTxn(nullptr), m_cursor(nullptr), m_database(database) +BerkeleyBatch::BerkeleyBatch(BerkeleyDatabase& database, const bool read_only, bool fFlushOnCloseIn) : m_database(database) { database.AddRef(); database.Open(); diff --git a/src/wallet/bdb.h b/src/wallet/bdb.h index 1d5f21e88d23..436e55736873 100644 --- a/src/wallet/bdb.h +++ b/src/wallet/bdb.h @@ -189,10 +189,10 @@ class BerkeleyBatch : public DatabaseBatch bool HasKey(CDataStream&& key) override; protected: - Db* pdb; + Db* pdb{nullptr}; std::string strFile; - DbTxn* activeTxn; - Dbc* m_cursor; + DbTxn* activeTxn{nullptr}; + Dbc* m_cursor{nullptr}; bool fReadOnly; bool fFlushOnClose; BerkeleyEnvironment *env; diff --git a/src/wallet/bip39_english.h b/src/wallet/bip39_english.h index 19547f512fa1..aee5cbd39063 100644 --- a/src/wallet/bip39_english.h +++ b/src/wallet/bip39_english.h @@ -2073,7 +2073,7 @@ const char * const wordlist[] = { "zero", "zone", "zoo", -0, +nullptr, }; #endif // BITCOIN_WALLET_BIP39_ENGLISH_H diff --git a/src/wallet/db.h b/src/wallet/db.h index fbd0e989c59c..259d09efb45b 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -105,7 +105,7 @@ class WalletDatabase { public: /** Create dummy DB handle */ - WalletDatabase() : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0) {} + WalletDatabase() : nUpdateCounter(0) {} virtual ~WalletDatabase() {}; /** Open the database if it is not already opened. */ @@ -147,9 +147,9 @@ class WalletDatabase virtual std::string Format() = 0; std::atomic nUpdateCounter; - unsigned int nLastSeen; - unsigned int nLastFlushed; - int64_t nLastWalletUpdate; + unsigned int nLastSeen{0}; + unsigned int nLastFlushed{0}; + int64_t nLastWalletUpdate{0}; /** Make a DatabaseBatch connected to this database */ virtual std::unique_ptr MakeBatch(bool flush_on_close = true) = 0; diff --git a/src/wallet/hdchain.h b/src/wallet/hdchain.h index 3a1d21b36200..e2bcc52804e5 100644 --- a/src/wallet/hdchain.h +++ b/src/wallet/hdchain.h @@ -9,13 +9,9 @@ namespace wallet { /* hd account data model */ -class CHDAccount -{ -public: - uint32_t nExternalChainCounter; - uint32_t nInternalChainCounter; - - CHDAccount() : nExternalChainCounter(0), nInternalChainCounter(0) {} +struct CHDAccount { + uint32_t nExternalChainCounter{0}; + uint32_t nInternalChainCounter{0}; SERIALIZE_METHODS(CHDAccount, obj) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 0ac939954c42..5a3318d73c94 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -268,7 +268,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati CKeyingMaterial vMasterKey GUARDED_BY(cs_wallet); //! if fOnlyMixingAllowed is true, only mixing should be allowed in unlocked wallet - bool fOnlyMixingAllowed; + bool fOnlyMixingAllowed{false}; bool Unlock(const CKeyingMaterial& vMasterKeyIn, bool fForMixingOnly = false); @@ -461,8 +461,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati /** Construct wallet with specified name and database implementation. */ CWallet(interfaces::Chain* chain, interfaces::CoinJoin::Loader* coinjoin_loader, const std::string& name, const ArgsManager& args, std::unique_ptr database) - : fOnlyMixingAllowed(false), - m_args(args), + : m_args(args), m_chain(chain), m_coinjoin_loader(coinjoin_loader), m_name(name), @@ -1095,10 +1094,10 @@ class WalletRescanReserver using Clock = std::chrono::steady_clock; using NowFn = std::function; CWallet& m_wallet; - bool m_could_reserve; + bool m_could_reserve{false}; NowFn m_now; public: - explicit WalletRescanReserver(CWallet& w) : m_wallet(w), m_could_reserve(false) {} + explicit WalletRescanReserver(CWallet& w) : m_wallet(w) {} bool reserve() { diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index 2f115b93d001..725a98fe8fb3 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -35,7 +35,7 @@ class CZMQAbstractNotifier public: static const int DEFAULT_ZMQ_SNDHWM {1000}; - CZMQAbstractNotifier() : psocket(nullptr), outbound_message_high_water_mark(DEFAULT_ZMQ_SNDHWM) { } + CZMQAbstractNotifier() : outbound_message_high_water_mark(DEFAULT_ZMQ_SNDHWM) {} virtual ~CZMQAbstractNotifier(); template @@ -78,7 +78,7 @@ class CZMQAbstractNotifier virtual bool NotifyRecoveredSig(const std::shared_ptr& sig); protected: - void *psocket; + void* psocket{nullptr}; std::string type; std::string address; int outbound_message_high_water_mark; // aka SNDHWM diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 423089ed1d94..904e9dca9f27 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -22,7 +22,7 @@ #include #include -CZMQNotificationInterface::CZMQNotificationInterface() : pcontext(nullptr) +CZMQNotificationInterface::CZMQNotificationInterface() { } diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h index 1151941aec51..bfc5b0b4680c 100644 --- a/src/zmq/zmqnotificationinterface.h +++ b/src/zmq/zmqnotificationinterface.h @@ -45,7 +45,7 @@ class CZMQNotificationInterface final : public CValidationInterface private: CZMQNotificationInterface(); - void *pcontext; + void* pcontext{nullptr}; std::list> notifiers; };