Skip to content

Commit 7b3343f

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25108: tidy: add modernize-use-default-member-init
ac6fbf2 tidy: use modernize-use-default-member-init (fanquake) 7aa40f5 refactor: use C++11 default initializers (fanquake) Pull request description: Refactor and then enable [`modernize-use-default-member-init`](https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default-member-init.html) in our `clang-tidy` job. Top commit has no ACKs. Tree-SHA512: 536b406f20639f8c588fe9e96175ec60c7bb825506b2670b562370b2f572801c24203c483443be3c199e1b958c0765d4532e57c57a4e78689162a1dd422d844f
2 parents e016c00 + ac6fbf2 commit 7b3343f

40 files changed

+59
-88
lines changed

src/.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
Checks: '
22
-*,
33
bugprone-argument-comment,
4+
modernize-use-default-member-init,
45
modernize-use-nullptr,
56
readability-redundant-declaration,
67
'
78
WarningsAsErrors: '
89
bugprone-argument-comment,
10+
modernize-use-default-member-init,
911
modernize-use-nullptr,
1012
readability-redundant-declaration,
1113
'

src/bench/checkqueue.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
3030

3131
struct PrevectorJob {
3232
prevector<PREVECTOR_SIZE, uint8_t> p;
33-
PrevectorJob(){
34-
}
33+
PrevectorJob() = default;
3534
explicit PrevectorJob(FastRandomContext& insecure_rand){
3635
p.resize(insecure_rand.randrange(PREVECTOR_SIZE*2));
3736
}

src/bench/prevector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <bench/bench.h>
1111

1212
struct nontrivial_t {
13-
int x;
14-
nontrivial_t() :x(-1) {}
13+
int x{-1};
14+
nontrivial_t() = default;
1515
SERIALIZE_METHODS(nontrivial_t, obj) { READWRITE(obj.x); }
1616
};
1717
static_assert(!std::is_trivially_default_constructible<nontrivial_t>::value,

src/bitcoin-cli.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ static int AppInitRPC(int argc, char* argv[])
180180
/** Reply structure for request_done to fill in */
181181
struct HTTPReply
182182
{
183-
HTTPReply(): status(0), error(-1) {}
183+
HTTPReply() = default;
184184

185-
int status;
186-
int error;
185+
int status{0};
186+
int error{-1};
187187
std::string body;
188188
};
189189

@@ -244,7 +244,7 @@ static void http_error_cb(enum evhttp_request_error err, void *ctx)
244244
class BaseRequestHandler
245245
{
246246
public:
247-
virtual ~BaseRequestHandler() {}
247+
virtual ~BaseRequestHandler() = default;
248248
virtual UniValue PrepareRequest(const std::string& method, const std::vector<std::string>& args) = 0;
249249
virtual UniValue ProcessReply(const UniValue &batch_in) = 0;
250250
};

src/httpserver.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,16 @@ class WorkQueue
7373
Mutex cs;
7474
std::condition_variable cond GUARDED_BY(cs);
7575
std::deque<std::unique_ptr<WorkItem>> queue GUARDED_BY(cs);
76-
bool running GUARDED_BY(cs);
76+
bool running GUARDED_BY(cs){true};
7777
const size_t maxDepth;
7878

7979
public:
80-
explicit WorkQueue(size_t _maxDepth) : running(true),
81-
maxDepth(_maxDepth)
80+
explicit WorkQueue(size_t _maxDepth) : maxDepth(_maxDepth)
8281
{
8382
}
8483
/** Precondition: worker threads have all stopped (they have been joined).
8584
*/
86-
~WorkQueue()
87-
{
88-
}
85+
~WorkQueue() = default;
8986
/** Enqueue a work item */
9087
bool Enqueue(WorkItem* item) EXCLUSIVE_LOCKS_REQUIRED(!cs)
9188
{

src/index/txindex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ TxIndex::TxIndex(size_t n_cache_size, bool f_memory, bool f_wipe)
5252
: m_db(std::make_unique<TxIndex::DB>(n_cache_size, f_memory, f_wipe))
5353
{}
5454

55-
TxIndex::~TxIndex() {}
55+
TxIndex::~TxIndex() = default;
5656

5757
bool TxIndex::WriteBlock(const CBlock& block, const CBlockIndex* pindex)
5858
{

src/net.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,7 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
26912691
class CNetCleanup
26922692
{
26932693
public:
2694-
CNetCleanup() {}
2694+
CNetCleanup() = default;
26952695

26962696
~CNetCleanup()
26972697
{

src/netaddress.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ bool CNetAddr::SetNetFromBIP155Network(uint8_t possible_bip155_net, size_t addre
9898
*
9999
* @note This address is considered invalid by CNetAddr::IsValid()
100100
*/
101-
CNetAddr::CNetAddr() {}
101+
CNetAddr::CNetAddr() = default;
102102

103103
void CNetAddr::SetIP(const CNetAddr& ipIn)
104104
{

src/node/context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
#include <validation.h>
1717

1818
namespace node {
19-
NodeContext::NodeContext() {}
20-
NodeContext::~NodeContext() {}
19+
NodeContext::NodeContext() = default;
20+
NodeContext::~NodeContext() = default;
2121
} // namespace node

src/policy/fees.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,7 @@ CBlockPolicyEstimator::CBlockPolicyEstimator()
537537
}
538538
}
539539

540-
CBlockPolicyEstimator::~CBlockPolicyEstimator()
541-
{
542-
}
540+
CBlockPolicyEstimator::~CBlockPolicyEstimator() = default;
543541

544542
void CBlockPolicyEstimator::processTransaction(const CTxMemPoolEntry& entry, bool validFeeEstimate)
545543
{

0 commit comments

Comments
 (0)