Skip to content

Commit 21e2670

Browse files
committed
Merge #12434: [doc] dev-notes: Members should be initialized
fa94614 [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
2 parents 07d2d2a + fa94614 commit 21e2670

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

doc/developer-notes.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,8 @@ Threads
240240

241241
- DumpAddresses : Dumps IP addresses of nodes to peers.dat.
242242

243-
- ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used in 500ms.
244-
245243
- ThreadRPCServer : Remote procedure call handler, listens on port 8332 for connections and services them.
246244

247-
- BitcoinMiner : Generates bitcoins (if wallet is enabled).
248-
249245
- Shutdown : Does an orderly shutdown of everything.
250246

251247
Ignoring IDE/editor files
@@ -382,6 +378,18 @@ C++ data structures
382378
- *Rationale*: Easier to understand what is happening, thus easier to spot mistakes, even for those
383379
that are not language lawyers
384380

381+
- Initialize all non-static class members where they are defined
382+
383+
- *Rationale*: Initializing the members in the declaration makes it easy to spot uninitialized ones,
384+
and avoids accidentally reading uninitialized memory
385+
386+
```cpp
387+
class A
388+
{
389+
uint32_t m_count{0};
390+
}
391+
```
392+
385393
Strings and formatting
386394
------------------------
387395
@@ -417,11 +425,11 @@ member name:
417425
```c++
418426
class AddressBookPage
419427
{
420-
Mode mode;
428+
Mode m_mode;
421429
}
422430
423431
AddressBookPage::AddressBookPage(Mode _mode) :
424-
mode(_mode)
432+
m_mode(_mode)
425433
...
426434
```
427435

src/miner.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
#include <queue>
3131
#include <utility>
3232

33-
//////////////////////////////////////////////////////////////////////////////
34-
//
35-
// BitcoinMiner
36-
//
37-
38-
//
3933
// Unconfirmed transactions in the memory pool often depend on other
4034
// transactions in the memory pool. When we select transactions from the
4135
// pool, we select by highest fee rate of a transaction combined with all

0 commit comments

Comments
 (0)