aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2019-10-28 15:09:56 -0400
committerMarcoFalke <falke.marco@gmail.com>2019-10-28 15:10:06 -0400
commit4c1090c882ea15ba4d10a2f7f320f3c0eb490ebd (patch)
tree60332191fe0bd4c847c60dc6a4751f77e3be6e2a /src/util
parentcfec3e01b4d6153efecc1d767511c616029cb974 (diff)
parentc72906dcc11a73fa06a0adf97557fa756b551bee (diff)
Merge #17279: refactor: Remove redundant c_str() calls in formatting
c72906dcc11a73fa06a0adf97557fa756b551bee refactor: Remove redundant c_str() calls in formatting (Wladimir J. van der Laan) Pull request description: Our formatter, tinyformat, *never* needs `c_str()` for strings. Still, many places call it redundantly, resulting in longer code and a slight overhead. Remove redundant `c_str()` calls for: - `strprintf` - `LogPrintf` - `tfm::format` (also, combined with #17095, I think this improves logging in case of unexpected embedded NULL characters) ACKs for top commit: ryanofsky: Code review ACK c72906dcc11a73fa06a0adf97557fa756b551bee. Easy to review with `git log -p -n1 --word-diff-regex=. -U0 c72906dcc11a73fa06a0adf97557fa756b551bee` Tree-SHA512: 9e21e7bed8aaff59b8b8aa11571396ddc265fb29608c2545b1fcdbbb36d65b37eb361db6688dd36035eab0c110f8de255375cfda50df3d9d7708bc092f67fefc
Diffstat (limited to 'src/util')
-rw-r--r--src/util/system.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/util/system.cpp b/src/util/system.cpp
index 526bf559c3..7da408eda5 100644
--- a/src/util/system.cpp
+++ b/src/util/system.cpp
@@ -305,7 +305,7 @@ NODISCARD static bool InterpretOption(std::string key, std::string val, unsigned
LogPrintf("Warning: parsed potentially confusing double-negative %s=%s\n", key, val);
val = "1";
} else {
- error = strprintf("Negating of %s is meaningless and therefore forbidden", key.c_str());
+ error = strprintf("Negating of %s is meaningless and therefore forbidden", key);
return false;
}
}
@@ -414,7 +414,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
return false;
}
} else {
- error = strprintf("Invalid parameter %s", key.c_str());
+ error = strprintf("Invalid parameter %s", key);
return false;
}
}
@@ -688,7 +688,7 @@ void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
LogPrintf("\n\n************************\n%s\n", message);
- tfm::format(std::cerr, "\n\n************************\n%s\n", message.c_str());
+ tfm::format(std::cerr, "\n\n************************\n%s\n", message);
}
fs::path GetDefaultDataDir()
@@ -870,7 +870,7 @@ bool ArgsManager::ReadConfigStream(std::istream& stream, const std::string& file
if (ignore_invalid_keys) {
LogPrintf("Ignoring unknown configuration value %s\n", option.first);
} else {
- error = strprintf("Invalid configuration value %s", option.first.c_str());
+ error = strprintf("Invalid configuration value %s", option.first);
return false;
}
}
@@ -925,7 +925,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
if (!ReadConfigStream(include_config, to_include, error, ignore_invalid_keys)) {
return false;
}
- LogPrintf("Included configuration file %s\n", to_include.c_str());
+ LogPrintf("Included configuration file %s\n", to_include);
} else {
error = "Failed to include configuration file " + to_include;
return false;
@@ -945,7 +945,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
}
}
for (const std::string& to_include : includeconf) {
- tfm::format(std::cerr, "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);
}
}
}
@@ -953,7 +953,7 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
// If datadir is changed in .conf file:
ClearDatadirCache();
if (!CheckDataDirOption()) {
- error = strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", "").c_str());
+ error = strprintf("specified data directory \"%s\" does not exist.", gArgs.GetArg("-datadir", ""));
return false;
}
return true;