Merge #16205: Refactor: Replace fprintf with tfm::format
fa8f195195
Replace remaining fprintf with tfm::format manually (MarcoFalke)fac03ec43a
scripted-diff: Replace fprintf with tfm::format (MarcoFalke)fa72a64b90
tinyformat: Add doc to Bitcoin Core specific strprintf (MarcoFalke) Pull request description: This should be a refactor except in the cases where we use the wrong format specifier [1], in which case this patch is a bug fix. [1] : e.g. depends: Add libevent compatibility patch for windows #8730 ACKs for commit fa8f19: promag: ACKfa8f195195
. Ideally this should be rebased before merge. practicalswift: utACKfa8f195195
Empact: ACKfa8f195195
laanwj: code review and lightly tested ACKfa8f195195
jonatack: ACKfa8f195195
from light code review, building, and running linter/unit tests/extended functional tests. Tree-SHA512: 65f648b0bc383e3266a5bdb4ad8c8a1908a719635d49e1cd321b91254be24dbc7e22290370178e29b98ddcb3fec0889de9cbae273c7140abc9793d849534a743
This commit is contained in:
commit
1a274bce4b
14 changed files with 67 additions and 68 deletions
|
@ -36,7 +36,7 @@ int main(int argc, char** argv)
|
|||
SetupBenchArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ int main(int argc, char** argv)
|
|||
|
||||
double scaling_factor;
|
||||
if (!ParseDouble(scaling_str, &scaling_factor)) {
|
||||
fprintf(stderr, "Error parsing scaling factor as double: %s\n", scaling_str.c_str());
|
||||
tfm::format(std::cerr, "Error parsing scaling factor as double: %s\n", scaling_str.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ static int AppInitRPC(int argc, char* argv[])
|
|||
SetupCliArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
|
||||
|
@ -115,26 +115,26 @@ static int AppInitRPC(int argc, char* argv[])
|
|||
strUsage += "\n" + gArgs.GetHelpMessage();
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s", strUsage.c_str());
|
||||
tfm::format(std::cout, "%s", strUsage.c_str());
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Error: too few parameters\n");
|
||||
tfm::format(std::cerr, "Error: too few parameters\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!fs::is_directory(GetDataDir(false))) {
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||
fprintf(stderr, "Error reading configuration file: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
|
||||
try {
|
||||
SelectBaseParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr, "Error: %s\n", e.what());
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return CONTINUE_EXECUTION;
|
||||
|
@ -495,7 +495,7 @@ static int CommandLineRPC(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (strPrint != "") {
|
||||
fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
|
||||
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint.c_str());
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ int main(int argc, char* argv[])
|
|||
#endif
|
||||
SetupEnvironment();
|
||||
if (!SetupNetworking()) {
|
||||
fprintf(stderr, "Error: Initializing networking failed\n");
|
||||
tfm::format(std::cerr, "Error: Initializing networking failed\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
event_set_log_callback(&libevent_log_cb);
|
||||
|
|
|
@ -82,7 +82,7 @@ static int AppInitRawTx(int argc, char* argv[])
|
|||
SetupBitcoinTxArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ static int AppInitRawTx(int argc, char* argv[])
|
|||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr, "Error: %s\n", e.what());
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -104,10 +104,10 @@ static int AppInitRawTx(int argc, char* argv[])
|
|||
"\n";
|
||||
strUsage += gArgs.GetHelpMessage();
|
||||
|
||||
fprintf(stdout, "%s", strUsage.c_str());
|
||||
tfm::format(std::cout, "%s", strUsage.c_str());
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Error: too few parameters\n");
|
||||
tfm::format(std::cerr, "Error: too few parameters\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -723,21 +723,21 @@ static void OutputTxJSON(const CTransaction& tx)
|
|||
TxToUniv(tx, uint256(), entry);
|
||||
|
||||
std::string jsonOutput = entry.write(4);
|
||||
fprintf(stdout, "%s\n", jsonOutput.c_str());
|
||||
tfm::format(std::cout, "%s\n", jsonOutput.c_str());
|
||||
}
|
||||
|
||||
static void OutputTxHash(const CTransaction& tx)
|
||||
{
|
||||
std::string strHexHash = tx.GetHash().GetHex(); // the hex-encoded transaction hash (aka the transaction id)
|
||||
|
||||
fprintf(stdout, "%s\n", strHexHash.c_str());
|
||||
tfm::format(std::cout, "%s\n", strHexHash.c_str());
|
||||
}
|
||||
|
||||
static void OutputTxHex(const CTransaction& tx)
|
||||
{
|
||||
std::string strHex = EncodeHexTx(tx);
|
||||
|
||||
fprintf(stdout, "%s\n", strHex.c_str());
|
||||
tfm::format(std::cout, "%s\n", strHex.c_str());
|
||||
}
|
||||
|
||||
static void OutputTx(const CTransaction& tx)
|
||||
|
@ -828,7 +828,7 @@ static int CommandLineRawTx(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (strPrint != "") {
|
||||
fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
|
||||
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint.c_str());
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ static bool WalletAppInit(int argc, char* argv[])
|
|||
SetupWalletToolArgs();
|
||||
std::string error_message;
|
||||
if (!gArgs.ParseParameters(argc, argv, error_message)) {
|
||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error_message.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error_message.c_str());
|
||||
return false;
|
||||
}
|
||||
if (argc < 2 || HelpRequested(gArgs)) {
|
||||
|
@ -48,7 +48,7 @@ static bool WalletAppInit(int argc, char* argv[])
|
|||
" bitcoin-wallet [options] <command>\n\n" +
|
||||
gArgs.GetHelpMessage();
|
||||
|
||||
fprintf(stdout, "%s", usage.c_str());
|
||||
tfm::format(std::cout, "%s", usage.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ static bool WalletAppInit(int argc, char* argv[])
|
|||
LogInstance().m_print_to_console = gArgs.GetBoolArg("-printtoconsole", gArgs.GetBoolArg("-debug", false));
|
||||
|
||||
if (!fs::is_directory(GetDataDir(false))) {
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
return false;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
|
@ -87,7 +87,7 @@ int main(int argc, char* argv[])
|
|||
for(int i = 1; i < argc; ++i) {
|
||||
if (!IsSwitchChar(argv[i][0])) {
|
||||
if (!method.empty()) {
|
||||
fprintf(stderr, "Error: two methods provided (%s and %s). Only one method should be provided.\n", method.c_str(), argv[i]);
|
||||
tfm::format(std::cerr, "Error: two methods provided (%s and %s). Only one method should be provided.\n", method.c_str(), argv[i]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
method = argv[i];
|
||||
|
@ -95,13 +95,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
if (method.empty()) {
|
||||
fprintf(stderr, "No method provided. Run `bitcoin-wallet -help` for valid methods.\n");
|
||||
tfm::format(std::cerr, "No method provided. Run `bitcoin-wallet -help` for valid methods.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// A name must be provided when creating a file
|
||||
if (method == "create" && !gArgs.IsArgSet("-wallet")) {
|
||||
fprintf(stderr, "Wallet name must be provided when creating a new wallet.\n");
|
||||
tfm::format(std::cerr, "Wallet name must be provided when creating a new wallet.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ static bool AppInit(int argc, char* argv[])
|
|||
SetupServerArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ static bool AppInit(int argc, char* argv[])
|
|||
strUsage += "\n" + gArgs.GetHelpMessage();
|
||||
}
|
||||
|
||||
fprintf(stdout, "%s", strUsage.c_str());
|
||||
tfm::format(std::cout, "%s", strUsage.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -96,25 +96,25 @@ static bool AppInit(int argc, char* argv[])
|
|||
{
|
||||
if (!fs::is_directory(GetDataDir(false)))
|
||||
{
|
||||
fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", gArgs.GetArg("-datadir", "").c_str());
|
||||
return false;
|
||||
}
|
||||
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||
fprintf(stderr, "Error reading configuration file: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
|
||||
return false;
|
||||
}
|
||||
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
|
||||
try {
|
||||
SelectParams(gArgs.GetChainName());
|
||||
} catch (const std::exception& e) {
|
||||
fprintf(stderr, "Error: %s\n", e.what());
|
||||
tfm::format(std::cerr, "Error: %s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Error out when loose non-argument tokens are encountered on command line
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (!IsSwitchChar(argv[i][0])) {
|
||||
fprintf(stderr, "Error: Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]);
|
||||
tfm::format(std::cerr, "Error: Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -146,18 +146,18 @@ static bool AppInit(int argc, char* argv[])
|
|||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
fprintf(stdout, "Bitcoin server starting\n");
|
||||
tfm::format(std::cout, "Bitcoin server starting\n");
|
||||
|
||||
// Daemonize
|
||||
if (daemon(1, 0)) { // don't chdir (1), do close FDs (0)
|
||||
fprintf(stderr, "Error: daemon() failed: %s\n", strerror(errno));
|
||||
tfm::format(std::cerr, "Error: daemon() failed: %s\n", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
#if defined(MAC_OSX)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#else
|
||||
fprintf(stderr, "Error: -daemon is not supported on this operating system\n");
|
||||
tfm::format(std::cerr, "Error: -daemon is not supported on this operating system\n");
|
||||
return false;
|
||||
#endif // HAVE_DECL_DAEMON
|
||||
}
|
||||
|
|
|
@ -108,14 +108,13 @@ static fs::path GetPidFile()
|
|||
|
||||
NODISCARD static bool CreatePidFile()
|
||||
{
|
||||
FILE* file = fsbridge::fopen(GetPidFile(), "w");
|
||||
fsbridge::ofstream file{GetPidFile()};
|
||||
if (file) {
|
||||
#ifdef WIN32
|
||||
fprintf(file, "%d\n", GetCurrentProcessId());
|
||||
tfm::format(file, "%d\n", GetCurrentProcessId());
|
||||
#else
|
||||
fprintf(file, "%d\n", getpid());
|
||||
tfm::format(file, "%d\n", getpid());
|
||||
#endif
|
||||
fclose(file);
|
||||
return true;
|
||||
} else {
|
||||
return InitError(strprintf(_("Unable to create the PID file '%s': %s"), GetPidFile().string(), std::strerror(errno)));
|
||||
|
|
|
@ -37,7 +37,7 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
|
|||
|
||||
if (!fSecure)
|
||||
LogPrintf("%s: %s\n", strCaption, message);
|
||||
fprintf(stderr, "%s: %s\n", strCaption.c_str(), message.c_str());
|
||||
tfm::format(std::cerr, "%s: %s\n", strCaption.c_str(), message.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ HelpMessageDialog::~HelpMessageDialog()
|
|||
void HelpMessageDialog::printToConsole()
|
||||
{
|
||||
// On other operating systems, the expected action is to print the message to the console.
|
||||
fprintf(stdout, "%s\n", qPrintable(text));
|
||||
tfm::format(std::cout, "%s\n", qPrintable(text));
|
||||
}
|
||||
|
||||
void HelpMessageDialog::showOrPrint()
|
||||
|
|
|
@ -57,7 +57,7 @@ struct CLockLocation {
|
|||
|
||||
std::string ToString() const
|
||||
{
|
||||
return tfm::format(
|
||||
return strprintf(
|
||||
"%s %s:%s%s (in thread %s)",
|
||||
mutexName, sourceFile, itostr(sourceLine), (fTry ? " (TRY)" : ""), m_thread_name);
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ static void potential_deadlock_detected(const std::pair<void*, void*>& mismatch,
|
|||
LogPrintf(" %s\n", i.second.ToString());
|
||||
}
|
||||
if (g_debug_lockorder_abort) {
|
||||
fprintf(stderr, "Assertion failed: detected inconsistent lock order at %s:%i, details in debug log.\n", __FILE__, __LINE__);
|
||||
tfm::format(std::cerr, "Assertion failed: detected inconsistent lock order at %s:%i, details in debug log.\n", __FILE__, __LINE__);
|
||||
abort();
|
||||
}
|
||||
throw std::logic_error("potential deadlock detected");
|
||||
|
@ -175,7 +175,7 @@ void AssertLockHeldInternal(const char* pszName, const char* pszFile, int nLine,
|
|||
for (const std::pair<void*, CLockLocation>& i : g_lockstack)
|
||||
if (i.first == cs)
|
||||
return;
|
||||
fprintf(stderr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||
tfm::format(std::cerr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ void AssertLockNotHeldInternal(const char* pszName, const char* pszFile, int nLi
|
|||
{
|
||||
for (const std::pair<void*, CLockLocation>& i : g_lockstack) {
|
||||
if (i.first == cs) {
|
||||
fprintf(stderr, "Assertion failed: lock %s held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||
tfm::format(std::cerr, "Assertion failed: lock %s held in %s:%i; locks held:\n%s", pszName, pszFile, nLine, LocksHeld().c_str());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1063,6 +1063,7 @@ std::string format(const std::string &fmt, const Args&... args)
|
|||
|
||||
} // namespace tinyformat
|
||||
|
||||
/** Format arguments and return the string or write to given std::ostream (see tinyformat::format doc for details) */
|
||||
#define strprintf tfm::format
|
||||
|
||||
#endif // TINYFORMAT_H_INCLUDED
|
||||
|
|
|
@ -673,7 +673,7 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
|
|||
{
|
||||
std::string message = FormatException(pex, pszThread);
|
||||
LogPrintf("\n\n************************\n%s\n", message);
|
||||
fprintf(stderr, "\n\n************************\n%s\n", message.c_str());
|
||||
tfm::format(std::cerr, "\n\n************************\n%s\n", message.c_str());
|
||||
}
|
||||
|
||||
fs::path GetDefaultDataDir()
|
||||
|
@ -933,7 +933,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
|
|||
}
|
||||
}
|
||||
for (const std::string& to_include : includeconf) {
|
||||
fprintf(stderr, "warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n", to_include.c_str());
|
||||
tfm::format(std::cerr, "warning: -includeconf cannot be used from included files; ignoring -includeconf=%s\n", to_include.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ static void WalletToolReleaseWallet(CWallet* wallet)
|
|||
static std::shared_ptr<CWallet> CreateWallet(const std::string& name, const fs::path& path)
|
||||
{
|
||||
if (fs::exists(path)) {
|
||||
fprintf(stderr, "Error: File exists already\n");
|
||||
tfm::format(std::cerr, "Error: File exists already\n");
|
||||
return nullptr;
|
||||
}
|
||||
// dummy chain interface
|
||||
|
@ -30,7 +30,7 @@ static std::shared_ptr<CWallet> CreateWallet(const std::string& name, const fs::
|
|||
bool first_run = true;
|
||||
DBErrors load_wallet_ret = wallet_instance->LoadWallet(first_run);
|
||||
if (load_wallet_ret != DBErrors::LOAD_OK) {
|
||||
fprintf(stderr, "Error creating %s", name.c_str());
|
||||
tfm::format(std::cerr, "Error creating %s", name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ static std::shared_ptr<CWallet> CreateWallet(const std::string& name, const fs::
|
|||
CPubKey seed = wallet_instance->GenerateNewSeed();
|
||||
wallet_instance->SetHDSeed(seed);
|
||||
|
||||
fprintf(stdout, "Topping up keypool...\n");
|
||||
tfm::format(std::cout, "Topping up keypool...\n");
|
||||
wallet_instance->TopUpKeyPool();
|
||||
return wallet_instance;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static std::shared_ptr<CWallet> CreateWallet(const std::string& name, const fs::
|
|||
static std::shared_ptr<CWallet> LoadWallet(const std::string& name, const fs::path& path)
|
||||
{
|
||||
if (!fs::exists(path)) {
|
||||
fprintf(stderr, "Error: Wallet files does not exist\n");
|
||||
tfm::format(std::cerr, "Error: Wallet files does not exist\n");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -59,28 +59,28 @@ static std::shared_ptr<CWallet> LoadWallet(const std::string& name, const fs::pa
|
|||
bool first_run;
|
||||
load_wallet_ret = wallet_instance->LoadWallet(first_run);
|
||||
} catch (const std::runtime_error&) {
|
||||
fprintf(stderr, "Error loading %s. Is wallet being used by another process?\n", name.c_str());
|
||||
tfm::format(std::cerr, "Error loading %s. Is wallet being used by another process?\n", name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (load_wallet_ret != DBErrors::LOAD_OK) {
|
||||
wallet_instance = nullptr;
|
||||
if (load_wallet_ret == DBErrors::CORRUPT) {
|
||||
fprintf(stderr, "Error loading %s: Wallet corrupted", name.c_str());
|
||||
tfm::format(std::cerr, "Error loading %s: Wallet corrupted", name.c_str());
|
||||
return nullptr;
|
||||
} else if (load_wallet_ret == DBErrors::NONCRITICAL_ERROR) {
|
||||
fprintf(stderr, "Error reading %s! All keys read correctly, but transaction data"
|
||||
tfm::format(std::cerr, "Error reading %s! All keys read correctly, but transaction data"
|
||||
" or address book entries might be missing or incorrect.",
|
||||
name.c_str());
|
||||
} else if (load_wallet_ret == DBErrors::TOO_NEW) {
|
||||
fprintf(stderr, "Error loading %s: Wallet requires newer version of %s",
|
||||
tfm::format(std::cerr, "Error loading %s: Wallet requires newer version of %s",
|
||||
name.c_str(), PACKAGE_NAME);
|
||||
return nullptr;
|
||||
} else if (load_wallet_ret == DBErrors::NEED_REWRITE) {
|
||||
fprintf(stderr, "Wallet needed to be rewritten: restart %s to complete", PACKAGE_NAME);
|
||||
tfm::format(std::cerr, "Wallet needed to be rewritten: restart %s to complete", PACKAGE_NAME);
|
||||
return nullptr;
|
||||
} else {
|
||||
fprintf(stderr, "Error loading %s", name.c_str());
|
||||
tfm::format(std::cerr, "Error loading %s", name.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -92,12 +92,12 @@ static void WalletShowInfo(CWallet* wallet_instance)
|
|||
{
|
||||
LOCK(wallet_instance->cs_wallet);
|
||||
|
||||
fprintf(stdout, "Wallet info\n===========\n");
|
||||
fprintf(stdout, "Encrypted: %s\n", wallet_instance->IsCrypted() ? "yes" : "no");
|
||||
fprintf(stdout, "HD (hd seed available): %s\n", wallet_instance->GetHDChain().seed_id.IsNull() ? "no" : "yes");
|
||||
fprintf(stdout, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
|
||||
fprintf(stdout, "Transactions: %zu\n", wallet_instance->mapWallet.size());
|
||||
fprintf(stdout, "Address Book: %zu\n", wallet_instance->mapAddressBook.size());
|
||||
tfm::format(std::cout, "Wallet info\n===========\n");
|
||||
tfm::format(std::cout, "Encrypted: %s\n", wallet_instance->IsCrypted() ? "yes" : "no");
|
||||
tfm::format(std::cout, "HD (hd seed available): %s\n", wallet_instance->GetHDChain().seed_id.IsNull() ? "no" : "yes");
|
||||
tfm::format(std::cout, "Keypool Size: %u\n", wallet_instance->GetKeyPoolSize());
|
||||
tfm::format(std::cout, "Transactions: %zu\n", wallet_instance->mapWallet.size());
|
||||
tfm::format(std::cout, "Address Book: %zu\n", wallet_instance->mapAddressBook.size());
|
||||
}
|
||||
|
||||
bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
||||
|
@ -112,12 +112,12 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
|||
}
|
||||
} else if (command == "info") {
|
||||
if (!fs::exists(path)) {
|
||||
fprintf(stderr, "Error: no wallet file at %s\n", name.c_str());
|
||||
tfm::format(std::cerr, "Error: no wallet file at %s\n", name.c_str());
|
||||
return false;
|
||||
}
|
||||
std::string error;
|
||||
if (!WalletBatch::VerifyEnvironment(path, error)) {
|
||||
fprintf(stderr, "Error loading %s. Is wallet being used by other process?\n", name.c_str());
|
||||
tfm::format(std::cerr, "Error loading %s. Is wallet being used by other process?\n", name.c_str());
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<CWallet> wallet_instance = LoadWallet(name, path);
|
||||
|
@ -125,7 +125,7 @@ bool ExecuteWalletToolFunc(const std::string& command, const std::string& name)
|
|||
WalletShowInfo(wallet_instance.get());
|
||||
wallet_instance->Flush(true);
|
||||
} else {
|
||||
fprintf(stderr, "Invalid command: %s\n", command.c_str());
|
||||
tfm::format(std::cerr, "Invalid command: %s\n", command.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ export LC_ALL=C
|
|||
FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS=(
|
||||
"FatalError,0"
|
||||
"fprintf,1"
|
||||
"tfm::format,1" # Assuming tfm::::format(std::ostream&, ...
|
||||
"LogConnectFailure,1"
|
||||
"LogPrint,1"
|
||||
"LogPrintf,0"
|
||||
|
|
|
@ -8,7 +8,6 @@ KNOWN_VIOLATIONS=(
|
|||
"src/dbwrapper.cpp:.*vsnprintf"
|
||||
"src/httprpc.cpp.*trim"
|
||||
"src/init.cpp:.*atoi"
|
||||
"src/init.cpp:.*fprintf"
|
||||
"src/qt/rpcconsole.cpp:.*atoi"
|
||||
"src/rest.cpp:.*strtol"
|
||||
"src/test/dbwrapper_tests.cpp:.*snprintf"
|
||||
|
@ -85,7 +84,7 @@ LOCALE_DEPENDENT_FUNCTIONS=(
|
|||
mbtowc # LC_CTYPE
|
||||
mktime
|
||||
normalize # boost::locale::normalize
|
||||
# printf # LC_NUMERIC
|
||||
printf # LC_NUMERIC
|
||||
putwc
|
||||
putwchar
|
||||
scanf # LC_NUMERIC
|
||||
|
@ -189,8 +188,7 @@ GIT_GREP_OUTPUT=$(git grep -E "[^a-zA-Z0-9_\`'\"<>](${REGEXP_LOCALE_DEPENDENT_FU
|
|||
EXIT_CODE=0
|
||||
for LOCALE_DEPENDENT_FUNCTION in "${LOCALE_DEPENDENT_FUNCTIONS[@]}"; do
|
||||
MATCHES=$(grep -E "[^a-zA-Z0-9_\`'\"<>]${LOCALE_DEPENDENT_FUNCTION}(_r|_s)?[^a-zA-Z0-9_\`'\"<>]" <<< "${GIT_GREP_OUTPUT}" | \
|
||||
grep -vE "\.(c|cpp|h):\s*(//|\*|/\*|\").*${LOCALE_DEPENDENT_FUNCTION}" | \
|
||||
grep -vE 'fprintf\(.*(stdout|stderr)')
|
||||
grep -vE "\.(c|cpp|h):\s*(//|\*|/\*|\").*${LOCALE_DEPENDENT_FUNCTION}")
|
||||
if [[ ${REGEXP_IGNORE_EXTERNAL_DEPENDENCIES} != "" ]]; then
|
||||
MATCHES=$(grep -vE "${REGEXP_IGNORE_EXTERNAL_DEPENDENCIES}" <<< "${MATCHES}")
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue