mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 22:24:05 +01:00
refactor: Remove redundant c_str() calls in formatting
Our formatter, tinyformat, *never* needs `c_str()` for strings. Remove redundant `c_str()` calls for: - `strprintf` - `LogPrintf` - `tfm::format`
This commit is contained in:
@@ -105,7 +105,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
SetupCliArgs();
|
||||
std::string error;
|
||||
if (!gArgs.ParseParameters(argc, argv, error)) {
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error parsing command line arguments: %s\n", error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) {
|
||||
@@ -119,7 +119,7 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
strUsage += "\n" + gArgs.GetHelpMessage();
|
||||
}
|
||||
|
||||
tfm::format(std::cout, "%s", strUsage.c_str());
|
||||
tfm::format(std::cout, "%s", strUsage);
|
||||
if (argc < 2) {
|
||||
tfm::format(std::cerr, "Error: too few parameters\n");
|
||||
return EXIT_FAILURE;
|
||||
@@ -127,11 +127,11 @@ static int AppInitRPC(int argc, char* argv[])
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
if (!CheckDataDirOption()) {
|
||||
tfm::format(std::cerr, "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", ""));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (!gArgs.ReadConfigFiles(error, true)) {
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error.c_str());
|
||||
tfm::format(std::cerr, "Error reading configuration file: %s\n", error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// Check for -chain, -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
|
||||
@@ -393,7 +393,7 @@ static UniValue CallRPC(BaseRequestHandler *rh, const std::string& strMethod, co
|
||||
if (failedToGetAuthCookie) {
|
||||
throw std::runtime_error(strprintf(
|
||||
"Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set. See -rpcpassword and -stdinrpcpass. Configuration file: (%s)",
|
||||
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string().c_str()));
|
||||
GetConfigFile(gArgs.GetArg("-conf", BITCOIN_CONF_FILENAME)).string()));
|
||||
} else {
|
||||
throw std::runtime_error("Authorization failed: Incorrect rpcuser or rpcpassword");
|
||||
}
|
||||
@@ -541,7 +541,7 @@ static int CommandLineRPC(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (strPrint != "") {
|
||||
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint.c_str());
|
||||
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint);
|
||||
}
|
||||
return nRet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user