From 28879fc052a30bb36314bfb6d8ec96bbb7945738 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 5 Mar 2018 17:38:56 +0100 Subject: [PATCH] Merge #12434: [doc] dev-notes: Members should be initialized fa9461473 [doc] dev-notes: Members should be initialized (MarcoFalke) Pull request description: Also, remove mention of threads that were removed long ago. Motivation: Make it easier to spot bugs such as #11654 and #12426 Tree-SHA512: 8ca1cb54e830e9368803bd98a8b08c39bf2d46f079094ed7e070b32ae15a6e611ce98d7a614f897803309f4728575e6bc9357fab1157c53d2536417eb8271653 --- doc/developer-notes.md | 18 ++++++++++++++---- src/miner.cpp | 6 ------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index dc9d2bd3c0..d60e877a4c 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -244,8 +244,6 @@ Threads - DumpAddresses : Dumps IP addresses of nodes to peers.dat. -- ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms. - - ThreadRPCServer : Remote procedure call handler, listens on port 9998 for connections and services them. - Shutdown : Does an orderly shutdown of everything. @@ -395,6 +393,18 @@ C++ data structures - *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those that are not language lawyers +- Initialize all non-static class members where they are defined + + - *Rationale*: Initializing the members in the declaration makes it easy to spot uninitialized ones, + and avoids accidentally reading uninitialized memory + +```cpp +class A +{ + uint32_t m_count{0}; +} +``` + Strings and formatting ------------------------ @@ -430,11 +440,11 @@ member name: ```c++ class AddressBookPage { - Mode mode; + Mode m_mode; } AddressBookPage::AddressBookPage(Mode _mode) : - mode(_mode) + m_mode(_mode) ... ``` diff --git a/src/miner.cpp b/src/miner.cpp index ef160cf047..d1b725e3e0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -42,12 +42,6 @@ #include #include -////////////////////////////////////////////////////////////////////////////// -// -// DashMiner -// - -// // Unconfirmed transactions in the memory pool often depend on other // transactions in the memory pool. When we select transactions from the // pool, we select by highest fee rate of a transaction combined with all