Skip to content

Commit fa60fa3

Browse files
author
MarcoFalke
committed
bitcoin-tidy: Apply bitcoin-unterminated-logprintf to spkm as well
1 parent faa1143 commit fa60fa3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

contrib/devtools/bitcoin-tidy/example_logprintf.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ class CWallet
4343
};
4444
};
4545

46+
struct ScriptPubKeyMan
47+
{
48+
std::string GetDisplayName() const
49+
{
50+
return "default wallet";
51+
}
52+
53+
template <typename... Params>
54+
void WalletLogPrintf(const char* fmt, Params... parameters) const
55+
{
56+
LogPrintf(("%s " + std::string{fmt}).c_str(), GetDisplayName(), parameters...);
57+
};
58+
};
59+
4660
void good_func()
4761
{
4862
LogPrintf("hello world!\n");
@@ -51,6 +65,8 @@ void good_func2()
5165
{
5266
CWallet wallet;
5367
wallet.WalletLogPrintf("hi\n");
68+
ScriptPubKeyMan spkm;
69+
spkm.WalletLogPrintf("hi\n");
5470

5571
const CWallet& walletref = wallet;
5672
walletref.WalletLogPrintf("hi\n");
@@ -80,6 +96,8 @@ void bad_func5()
8096
{
8197
CWallet wallet;
8298
wallet.WalletLogPrintf("hi");
99+
ScriptPubKeyMan spkm;
100+
spkm.WalletLogPrintf("hi");
83101

84102
const CWallet& walletref = wallet;
85103
walletref.WalletLogPrintf("hi");

contrib/devtools/bitcoin-tidy/logprintf.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ void LogPrintfCheck::registerMatchers(clang::ast_matchers::MatchFinder* finder)
3636
this);
3737

3838
/*
39-
CWallet wallet;
4039
auto walletptr = &wallet;
4140
wallet.WalletLogPrintf("foo");
4241
wallet->WalletLogPrintf("foo");
4342
*/
4443
finder->addMatcher(
4544
cxxMemberCallExpr(
46-
thisPointerType(qualType(hasDeclaration(cxxRecordDecl(hasName("CWallet"))))),
4745
callee(cxxMethodDecl(hasName("WalletLogPrintf"))),
4846
hasArgument(0, stringLiteral(unterminated()).bind("logstring"))),
4947
this);

0 commit comments

Comments
 (0)