Skip to content

Commit 0a13d15

Browse files
committed
Merge #20530: lint, refactor: Update cppcheck linter to c++17 and improve explicit usage
1e62350 refactor: Improve use of explicit keyword (Fabian Jahr) c502a6d lint: Use c++17 std in cppcheck linter (Fabian Jahr) Pull request description: I found the `extended-lint-cppcheck` linter still uses `std=c++11` when reviewing #20471. The only difference in the output after this change is one line is missing: ``` src/script/descriptor.cpp:159:5: warning: Struct 'PubkeyProvider' has a constructor with 1 argument that is not explicit. [noExplicitConstructor] ``` After some digging, I am still not sure why this one is ignored with c++17 when 40 other`noExplicitConstructor` warnings were still appearing. In the second commit, I fix these warnings, adding `explicit` where appropriate and adding fixes to ignore otherwise. ACKs for top commit: practicalswift: cr ACK 1e62350: patch looks correct! MarcoFalke: review ACK 1e62350 Tree-SHA512: dff7b324429a57160e217cf38d9ddbb6e70c6cb3d3e3e0bd4013d88e07afc2292c3df94d0acf7122e9d486322821682ecf15c8f2724a78667764c05d47f89a12
2 parents 3693fcc + 1e62350 commit 0a13d15

19 files changed

+32
-23
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ struct Peer {
451451
/** Work queue of items requested by this peer **/
452452
std::deque<CInv> m_getdata_requests GUARDED_BY(m_getdata_requests_mutex);
453453

454-
Peer(NodeId id) : m_id(id) {}
454+
explicit Peer(NodeId id) : m_id(id) {}
455455
};
456456

457457
using PeerRef = std::shared_ptr<Peer>;

src/node/interfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace {
6464
class NodeImpl : public Node
6565
{
6666
public:
67-
NodeImpl(NodeContext* context) { setContext(context); }
67+
explicit NodeImpl(NodeContext* context) { setContext(context); }
6868
void initLogging() override { InitLogging(*Assert(m_context->args)); }
6969
void initParameterInteraction() override { InitParameterInteraction(*Assert(m_context->args)); }
7070
bilingual_str getWarnings() override { return GetWarnings(true); }

src/pubkey.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class XOnlyPubKey
223223

224224
public:
225225
/** Construct an x-only pubkey from exactly 32 bytes. */
226-
XOnlyPubKey(Span<const unsigned char> bytes);
226+
explicit XOnlyPubKey(Span<const unsigned char> bytes);
227227

228228
/** Verify a Schnorr signature against this public key.
229229
*

src/qt/test/addressbooktests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Node;
1515
class AddressBookTests : public QObject
1616
{
1717
public:
18-
AddressBookTests(interfaces::Node& node) : m_node(node) {}
18+
explicit AddressBookTests(interfaces::Node& node) : m_node(node) {}
1919
interfaces::Node& m_node;
2020

2121
Q_OBJECT

src/qt/test/rpcnestedtests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Node;
1515
class RPCNestedTests : public QObject
1616
{
1717
public:
18-
RPCNestedTests(interfaces::Node& node) : m_node(node) {}
18+
explicit RPCNestedTests(interfaces::Node& node) : m_node(node) {}
1919
interfaces::Node& m_node;
2020

2121
Q_OBJECT

src/qt/test/wallettests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Node;
1515
class WalletTests : public QObject
1616
{
1717
public:
18-
WalletTests(interfaces::Node& node) : m_node(node) {}
18+
explicit WalletTests(interfaces::Node& node) : m_node(node) {}
1919
interfaces::Node& m_node;
2020

2121
Q_OBJECT

src/rpc/request.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class JSONRPCRequest
4040
std::string peerAddr;
4141
const util::Ref& context;
4242

43-
JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), fHelp(false), context(context) {}
43+
explicit JSONRPCRequest(const util::Ref& context) : id(NullUniValue), params(NullUniValue), fHelp(false), context(context) {}
4444

4545
//! Initializes request information from another request object and the
4646
//! given context. The implementation should be updated if any members are

src/script/descriptor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct PubkeyProvider
156156
uint32_t m_expr_index;
157157

158158
public:
159-
PubkeyProvider(uint32_t exp_index) : m_expr_index(exp_index) {}
159+
explicit PubkeyProvider(uint32_t exp_index) : m_expr_index(exp_index) {}
160160

161161
virtual ~PubkeyProvider() = default;
162162

src/script/standard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BaseHash
2828

2929
public:
3030
BaseHash() : m_hash() {}
31-
BaseHash(const HashType& in) : m_hash(in) {}
31+
explicit BaseHash(const HashType& in) : m_hash(in) {}
3232

3333
unsigned char* begin()
3434
{

src/test/fuzz/signature_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class FuzzedSignatureChecker : public BaseSignatureChecker
2424
FuzzedDataProvider& m_fuzzed_data_provider;
2525

2626
public:
27-
FuzzedSignatureChecker(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider(fuzzed_data_provider)
27+
explicit FuzzedSignatureChecker(FuzzedDataProvider& fuzzed_data_provider) : m_fuzzed_data_provider(fuzzed_data_provider)
2828
{
2929
}
3030

0 commit comments

Comments
 (0)