Skip to content

Commit 16b5b4b

Browse files
committed
Merge bitcoin#28579: refactor: Remove redundant checks in compat/assumptions.h
fa1a384 Move compat.h include from system.h to system.cpp (MarcoFalke) 8888753 Move compat/assumptions.h include to one place that actually needs it (MarcoFalke) 7777411 Remove __cplusplus from compat/assumptions.h (MarcoFalke) faa3d4f Remove duplicate NDEBUG check from compat/assumptions.h (MarcoFalke) Pull request description: Generally, compile-time checks should be close to the code that use them. Especially, since `compat/assumptions.h` is only included in one place, where iwyu suggests to remove it. Fix all issues: * The `NDEBUG` check is used in `util/check`, so it is redundant in `compat/assumptions.h`. * The `__cplusplus` check is redundant with `doc/dependencies.md` (see commit message). * Add missing `// IWYU pragma: keep` to avoid removing the include by accident. ACKs for top commit: achow101: ACK fa1a384 TheCharlatan: re-ACK fa1a384 theuni: ACK fa1a384 Tree-SHA512: f8b6db84be5d8844a2267345c0b1405fcbc39b8b5eeaa24db5b8412a74145fe44cf188b6b0c39cc2b062690ed37ca5b4662473484afe28dbec6469e79961389b
2 parents 75462b3 + fa1a384 commit 16b5b4b

File tree

6 files changed

+10
-28
lines changed

6 files changed

+10
-28
lines changed

src/common/system.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2022 The Bitcoin Core developers
2+
// Copyright (c) 2009-present The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -12,6 +12,7 @@
1212
#ifndef WIN32
1313
#include <sys/stat.h>
1414
#else
15+
#include <compat/compat.h>
1516
#include <codecvt>
1617
#endif
1718

src/common/system.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2009-2010 Satoshi Nakamoto
2-
// Copyright (c) 2009-2022 The Bitcoin Core developers
2+
// Copyright (c) 2009-present The Bitcoin Core developers
33
// Distributed under the MIT software license, see the accompanying
44
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
55

@@ -10,11 +10,7 @@
1010
#include <config/bitcoin-config.h>
1111
#endif
1212

13-
#include <compat/assumptions.h>
14-
#include <compat/compat.h>
15-
16-
#include <set>
17-
#include <stdint.h>
13+
#include <cstdint>
1814
#include <string>
1915

2016
// Application startup time (used for uptime calculation)

src/compat/assumptions.h

-14
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111
#include <cstddef>
1212
#include <limits>
1313

14-
// Assumption: We assume that the macro NDEBUG is not defined.
15-
// Example(s): We use assert(...) extensively with the assumption of it never
16-
// being a noop at runtime.
17-
#if defined(NDEBUG)
18-
# error "Bitcoin cannot be compiled without assertions."
19-
#endif
20-
21-
// Assumption: We assume a C++17 (ISO/IEC 14882:2017) compiler (minimum requirement).
22-
// Example(s): We assume the presence of C++17 features everywhere :-)
23-
// ISO Standard C++17 [cpp.predefined]p1:
24-
// "The name __cplusplus is defined to the value 201703L when compiling a C++
25-
// translation unit."
26-
static_assert(__cplusplus >= 201703L, "C++17 standard assumed");
27-
2814
// Assumption: We assume the floating-point types to fulfill the requirements of
2915
// IEC 559 (IEEE 754) standard.
3016
// Example(s): Floating-point division by zero in ConnectBlock, CreateTransaction

src/net_processing.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#include <hash.h>
1717
#include <headerssync.h>
1818
#include <index/blockfilterindex.h>
19+
#include <kernel/chain.h>
1920
#include <kernel/mempool_entry.h>
2021
#include <logging.h>
21-
#include <kernel/chain.h>
2222
#include <merkleblock.h>
2323
#include <netbase.h>
2424
#include <netmessagemaker.h>
@@ -39,7 +39,7 @@
3939
#include <txmempool.h>
4040
#include <txorphanage.h>
4141
#include <txrequest.h>
42-
#include <util/check.h> // For NDEBUG compile time check
42+
#include <util/check.h>
4343
#include <util/strencodings.h>
4444
#include <util/trace.h>
4545
#include <validation.h>

src/serialize.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#define BITCOIN_SERIALIZE_H
88

99
#include <attributes.h>
10+
#include <compat/assumptions.h> // IWYU pragma: keep
1011
#include <compat/endian.h>
12+
#include <prevector.h>
13+
#include <span.h>
1114

1215
#include <algorithm>
1316
#include <cstdint>
@@ -18,13 +21,9 @@
1821
#include <memory>
1922
#include <set>
2023
#include <string>
21-
#include <string.h>
2224
#include <utility>
2325
#include <vector>
2426

25-
#include <prevector.h>
26-
#include <span.h>
27-
2827
/**
2928
* The maximum size of a serialized object in bytes or number of elements
3029
* (for eg vectors) when the size is encoded as CompactSize.

src/validation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <txmempool.h>
4646
#include <uint256.h>
4747
#include <undo.h>
48-
#include <util/check.h> // For NDEBUG compile time check
48+
#include <util/check.h>
4949
#include <util/fs.h>
5050
#include <util/fs_helpers.h>
5151
#include <util/hasher.h>

0 commit comments

Comments
 (0)