0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

log: Remove NOLINT(bitcoin-unterminated-logprintf)

This commit is contained in:
MarcoFalke 2024-07-19 15:23:28 +02:00
parent ec74f45741
commit fa18fc7050
No known key found for this signature in database
3 changed files with 10 additions and 2 deletions

View file

@ -100,7 +100,7 @@ public:
assert(p <= limit);
base[std::min(bufsize - 1, (int)(p - base))] = '\0';
LogPrintLevel(BCLog::LEVELDB, BCLog::Level::Debug, "%s", base); // NOLINT(bitcoin-unterminated-logprintf)
LogDebug(BCLog::LEVELDB, "%s\n", util::RemoveSuffixView(base, "\n"));
if (base != buffer) {
delete[] base;
}

View file

@ -81,6 +81,14 @@ std::vector<T> Split(const Span<const char>& sp, char sep)
return std::string(TrimStringView(str, pattern));
}
[[nodiscard]] inline std::string_view RemoveSuffixView(std::string_view str, std::string_view suffix)
{
if (str.ends_with(suffix)) {
return str.substr(0, str.size() - suffix.size());
}
return str;
}
[[nodiscard]] inline std::string_view RemovePrefixView(std::string_view str, std::string_view prefix)
{
if (str.substr(0, prefix.size()) == prefix) {

View file

@ -2309,7 +2309,7 @@ OutputType CWallet::TransactionChangeType(const std::optional<OutputType>& chang
void CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm)
{
LOCK(cs_wallet);
WalletLogPrintf("CommitTransaction:\n%s", tx->ToString()); // NOLINT(bitcoin-unterminated-logprintf)
WalletLogPrintf("CommitTransaction:\n%s\n", util::RemoveSuffixView(tx->ToString(), "\n"));
// Add tx to wallet, because if it has change it's also ours,
// otherwise just for transaction history.