mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Remove redundant .c_str()s
After the tinyformat switch sprintf() family functions support passing actual std::string objects. Remove unnecessary c_str calls (236 of them) in logging and formatting.
This commit is contained in:
44
src/init.cpp
44
src/init.cpp
@@ -344,7 +344,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
FILE *file = fopen(path.string().c_str(), "rb");
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
LogPrintf("Importing %s...\n", path.string().c_str());
|
||||
LogPrintf("Importing %s...\n", path.string());
|
||||
LoadExternalBlockFile(file);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
|
||||
CTransaction::nMinTxFee = n;
|
||||
else
|
||||
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"].c_str()));
|
||||
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
|
||||
}
|
||||
if (mapArgs.count("-minrelaytxfee"))
|
||||
{
|
||||
@@ -520,14 +520,14 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
|
||||
CTransaction::nMinRelayTxFee = n;
|
||||
else
|
||||
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"].c_str()));
|
||||
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
|
||||
}
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if (mapArgs.count("-paytxfee"))
|
||||
{
|
||||
if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))
|
||||
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"].c_str()));
|
||||
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"]));
|
||||
if (nTransactionFee > 0.25 * COIN)
|
||||
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
|
||||
}
|
||||
@@ -540,7 +540,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
#ifdef ENABLE_WALLET
|
||||
// Wallet file must be a plain filename without a directory
|
||||
if (strWalletFile != boost::filesystem::basename(strWalletFile) + boost::filesystem::extension(strWalletFile))
|
||||
return InitError(strprintf(_("Wallet %s resides outside data directory %s"), strWalletFile.c_str(), strDataDir.c_str()));
|
||||
return InitError(strprintf(_("Wallet %s resides outside data directory %s"), strWalletFile, strDataDir));
|
||||
#endif
|
||||
// Make sure only a single Bitcoin process is using the data directory.
|
||||
boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
|
||||
@@ -548,17 +548,17 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (file) fclose(file);
|
||||
static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
|
||||
if (!lock.try_lock())
|
||||
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), strDataDir.c_str()));
|
||||
return InitError(strprintf(_("Cannot obtain a lock on data directory %s. Bitcoin is probably already running."), strDataDir));
|
||||
|
||||
if (GetBoolArg("-shrinkdebugfile", !fDebug))
|
||||
ShrinkDebugFile();
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
LogPrintf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
|
||||
LogPrintf("Bitcoin version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
if (!fLogTimestamps)
|
||||
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str());
|
||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
|
||||
LogPrintf("Using data directory %s\n", strDataDir.c_str());
|
||||
LogPrintf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()));
|
||||
LogPrintf("Default data directory %s\n", GetDefaultDataDir().string());
|
||||
LogPrintf("Using data directory %s\n", strDataDir);
|
||||
LogPrintf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD);
|
||||
std::ostringstream strErrors;
|
||||
|
||||
@@ -582,7 +582,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%"PRId64".bak", GetTime());
|
||||
try {
|
||||
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
|
||||
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str());
|
||||
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
|
||||
} catch(boost::filesystem::filesystem_error &error) {
|
||||
// failure is ok (well, not really, but it's not worse than what we started with)
|
||||
}
|
||||
@@ -590,7 +590,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
// try again
|
||||
if (!bitdb.Open(GetDataDir())) {
|
||||
// if it still fails, it probably means we can't even create the database env
|
||||
string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir.c_str());
|
||||
string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir);
|
||||
return InitError(msg);
|
||||
}
|
||||
}
|
||||
@@ -610,7 +610,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!"
|
||||
" Original wallet.dat saved as wallet.{timestamp}.bak in %s; if"
|
||||
" your balance or transactions are incorrect you should"
|
||||
" restore from a backup."), strDataDir.c_str());
|
||||
" restore from a backup."), strDataDir);
|
||||
InitWarning(msg);
|
||||
}
|
||||
if (r == CDBEnv::RECOVER_FAIL)
|
||||
@@ -631,7 +631,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"]) {
|
||||
enum Network net = ParseNetwork(snet);
|
||||
if (net == NET_UNROUTABLE)
|
||||
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet.c_str()));
|
||||
return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet));
|
||||
nets.insert(net);
|
||||
}
|
||||
for (int n = 0; n < NET_MAX; n++) {
|
||||
@@ -652,7 +652,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
if (mapArgs.count("-proxy")) {
|
||||
addrProxy = CService(mapArgs["-proxy"], 9050);
|
||||
if (!addrProxy.IsValid())
|
||||
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
|
||||
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"]));
|
||||
|
||||
if (!IsLimited(NET_IPV4))
|
||||
SetProxy(NET_IPV4, addrProxy, nSocksVersion);
|
||||
@@ -679,7 +679,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
else
|
||||
addrOnion = mapArgs.count("-onion")?CService(mapArgs["-onion"], 9050):CService(mapArgs["-tor"], 9050);
|
||||
if (!addrOnion.IsValid())
|
||||
return InitError(strprintf(_("Invalid -onion address: '%s'"), mapArgs.count("-onion")?mapArgs["-onion"].c_str():mapArgs["-tor"].c_str()));
|
||||
return InitError(strprintf(_("Invalid -onion address: '%s'"), mapArgs.count("-onion")?mapArgs["-onion"]:mapArgs["-tor"]));
|
||||
SetProxy(NET_TOR, addrOnion, 5);
|
||||
SetReachable(NET_TOR);
|
||||
}
|
||||
@@ -695,7 +695,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) {
|
||||
CService addrBind;
|
||||
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
|
||||
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind.c_str()));
|
||||
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
|
||||
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
|
||||
}
|
||||
}
|
||||
@@ -715,7 +715,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
BOOST_FOREACH(string strAddr, mapMultiArgs["-externalip"]) {
|
||||
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
|
||||
if (!addrLocal.IsValid())
|
||||
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr.c_str()));
|
||||
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
|
||||
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
|
||||
}
|
||||
}
|
||||
@@ -739,7 +739,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1);
|
||||
try {
|
||||
filesystem::create_hard_link(source, dest);
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string().c_str(), dest.string().c_str());
|
||||
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
|
||||
linked = true;
|
||||
} catch (filesystem::filesystem_error & e) {
|
||||
// Note: hardlink creation failing is not a disaster, it just means
|
||||
@@ -879,7 +879,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
}
|
||||
}
|
||||
if (nFound == 0)
|
||||
LogPrintf("No blocks matching %s were found\n", strMatch.c_str());
|
||||
LogPrintf("No blocks matching %s were found\n", strMatch);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -910,7 +910,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
else if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||
{
|
||||
strErrors << _("Wallet needed to be rewritten: restart Bitcoin to complete") << "\n";
|
||||
LogPrintf("%s", strErrors.str().c_str());
|
||||
LogPrintf("%s", strErrors.str());
|
||||
return InitError(strErrors.str());
|
||||
}
|
||||
else
|
||||
@@ -948,7 +948,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
pwalletMain->SetBestChain(chainActive.GetLocator());
|
||||
}
|
||||
|
||||
LogPrintf("%s", strErrors.str().c_str());
|
||||
LogPrintf("%s", strErrors.str());
|
||||
LogPrintf(" wallet %15"PRId64"ms\n", GetTimeMillis() - nStart);
|
||||
|
||||
RegisterWallet(pwalletMain);
|
||||
|
||||
Reference in New Issue
Block a user