diff --git a/src/sync.cpp b/src/sync.cpp index 7540819262..c0a3314765 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -94,34 +94,36 @@ LockData& GetLockData() { static void potential_deadlock_detected(const LockPair& mismatch, const LockStack& s1, const LockStack& s2) { - std::string strOutput = ""; - strOutput += "POTENTIAL DEADLOCK DETECTED\n"; - strOutput += "Previous lock order was:\n"; + std::string log_message{}; + log_message += "POTENTIAL DEADLOCK DETECTED\n"; + log_message += "Previous lock order was:\n"; for (const LockStackItem& i : s1) { + std::string prefix{}; if (i.first == mismatch.first) { - strOutput += " (1)"; + prefix = " (1)"; } if (i.first == mismatch.second) { - strOutput += " (2)"; + prefix = " (2)"; } - strOutput += strprintf(" %s\n", i.second.ToString()); + log_message += strprintf("%s %s\n", prefix, i.second.ToString()); } std::string mutex_a, mutex_b; - strOutput += "Current lock order is:\n"; + log_message += "Current lock order is:\n"; for (const LockStackItem& i : s2) { + std::string prefix{}; if (i.first == mismatch.first) { - strOutput += " (1)"; + prefix = " (1)"; mutex_a = i.second.Name(); } if (i.first == mismatch.second) { - strOutput += " (2)"; + prefix = " (2)"; mutex_b = i.second.Name(); } - strOutput += strprintf(" %s\n", i.second.ToString()); + log_message += strprintf("%s %s\n", prefix, i.second.ToString()); } - LogPrintf("%s\n", strOutput); + LogPrintf("%s\n", log_message); if (g_debug_lockorder_abort) { tfm::format(std::cerr, "Assertion failed: detected inconsistent lock order for %s, details in debug log.\n", s2.back().second.ToString()); diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index be9fdbb1c2..6bd9044da8 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -340,15 +340,15 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector& group util::insert(setCoinsRet, lowest_larger->m_outputs); nValueRet += lowest_larger->m_value; } else { - std::string s = "CWallet::SelectCoinsMinConf best subset: "; + std::string log_message{"Coin selection best subset: "}; for (unsigned int i = 0; i < applicable_groups.size(); i++) { if (vfBest[i]) { util::insert(setCoinsRet, applicable_groups[i].m_outputs); nValueRet += applicable_groups[i].m_value; - s += FormatMoney(applicable_groups[i].m_value) + " "; + log_message += strprintf("%s ", FormatMoney(applicable_groups[i].m_value)); } } - LogPrint(BCLog::SELECTCOINS, "%s - total %s\n", s, FormatMoney(nBest)); + LogPrint(BCLog::SELECTCOINS, "%stotal %s\n", log_message, FormatMoney(nBest)); } // There is no change in PS, so we know the fee beforehand,