mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 06:49:38 -04:00
refactor: starts/ends_with changes for clang-tidy 20
This commit is contained in:
parent
96a5cd8000
commit
2b85d31bcc
11 changed files with 16 additions and 16 deletions
|
@ -1220,7 +1220,7 @@ static int CommandLineRPC(int argc, char *argv[])
|
||||||
if (gArgs.GetBoolArg("-stdinwalletpassphrase", false)) {
|
if (gArgs.GetBoolArg("-stdinwalletpassphrase", false)) {
|
||||||
NO_STDIN_ECHO();
|
NO_STDIN_ECHO();
|
||||||
std::string walletPass;
|
std::string walletPass;
|
||||||
if (args.size() < 1 || args[0].substr(0, 16) != "walletpassphrase") {
|
if (args.size() < 1 || !args[0].starts_with("walletpassphrase")) {
|
||||||
throw std::runtime_error("-stdinwalletpassphrase is only applicable for walletpassphrase(change)");
|
throw std::runtime_error("-stdinwalletpassphrase is only applicable for walletpassphrase(change)");
|
||||||
}
|
}
|
||||||
if (!StdinReady()) {
|
if (!StdinReady()) {
|
||||||
|
|
|
@ -85,7 +85,7 @@ KeyInfo InterpretKey(std::string key)
|
||||||
result.section = key.substr(0, option_index);
|
result.section = key.substr(0, option_index);
|
||||||
key.erase(0, option_index + 1);
|
key.erase(0, option_index + 1);
|
||||||
}
|
}
|
||||||
if (key.substr(0, 2) == "no") {
|
if (key.starts_with("no")) {
|
||||||
key.erase(0, 2);
|
key.erase(0, 2);
|
||||||
result.negated = true;
|
result.negated = true;
|
||||||
}
|
}
|
||||||
|
@ -189,7 +189,7 @@ bool ArgsManager::ParseParameters(int argc, const char* const argv[], std::strin
|
||||||
// internet" warning, and clicks the Open button, macOS passes
|
// internet" warning, and clicks the Open button, macOS passes
|
||||||
// a unique process serial number (PSN) as -psn_... command-line
|
// a unique process serial number (PSN) as -psn_... command-line
|
||||||
// argument, which we filter out.
|
// argument, which we filter out.
|
||||||
if (key.substr(0, 5) == "-psn_") continue;
|
if (key.starts_with("-psn_")) continue;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (key == "-") break; //bitcoin-tx using stdin
|
if (key == "-") break; //bitcoin-tx using stdin
|
||||||
|
|
|
@ -65,7 +65,7 @@ static bool GetConfigOptions(std::istream& stream, const std::string& filepath,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
error = strprintf("parse error on line %i: %s", linenr, str);
|
error = strprintf("parse error on line %i: %s", linenr, str);
|
||||||
if (str.size() >= 2 && str.substr(0, 2) == "no") {
|
if (str.size() >= 2 && str.starts_with("no")) {
|
||||||
error += strprintf(", if you intended to specify a negated option, use %s=1 instead", str);
|
error += strprintf(", if you intended to specify a negated option, use %s=1 instead", str);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -83,7 +83,7 @@ CScript ParseScript(const std::string& s)
|
||||||
}
|
}
|
||||||
|
|
||||||
result << num.value();
|
result << num.value();
|
||||||
} else if (w.substr(0, 2) == "0x" && w.size() > 2 && IsHex(std::string(w.begin() + 2, w.end()))) {
|
} else if (w.starts_with("0x") && w.size() > 2 && IsHex(std::string(w.begin() + 2, w.end()))) {
|
||||||
// Raw hex data, inserted NOT pushed onto stack:
|
// Raw hex data, inserted NOT pushed onto stack:
|
||||||
std::vector<unsigned char> raw = ParseHex(std::string(w.begin() + 2, w.end()));
|
std::vector<unsigned char> raw = ParseHex(std::string(w.begin() + 2, w.end()));
|
||||||
result.insert(result.end(), raw.begin(), raw.end());
|
result.insert(result.end(), raw.begin(), raw.end());
|
||||||
|
|
|
@ -134,7 +134,7 @@ static bool multiUserAuthorized(std::string strUserPass)
|
||||||
|
|
||||||
static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut)
|
static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut)
|
||||||
{
|
{
|
||||||
if (strAuth.substr(0, 6) != "Basic ")
|
if (!strAuth.starts_with("Basic "))
|
||||||
return false;
|
return false;
|
||||||
std::string_view strUserPass64 = TrimStringView(std::string_view{strAuth}.substr(6));
|
std::string_view strUserPass64 = TrimStringView(std::string_view{strAuth}.substr(6));
|
||||||
auto userpass_data = DecodeBase64(strUserPass64);
|
auto userpass_data = DecodeBase64(strUserPass64);
|
||||||
|
|
|
@ -299,7 +299,7 @@ Session::Reply Session::SendRequestAndGetReply(const Sock& sock,
|
||||||
Reply reply;
|
Reply reply;
|
||||||
|
|
||||||
// Don't log the full "SESSION CREATE ..." because it contains our private key.
|
// Don't log the full "SESSION CREATE ..." because it contains our private key.
|
||||||
reply.request = request.substr(0, 14) == "SESSION CREATE" ? "SESSION CREATE ..." : request;
|
reply.request = request.starts_with("SESSION CREATE") ? "SESSION CREATE ..." : request;
|
||||||
|
|
||||||
// It could take a few minutes for the I2P router to reply as it is querying the I2P network
|
// It could take a few minutes for the I2P router to reply as it is querying the I2P network
|
||||||
// (when doing name lookup, for example). Notice: `RecvUntilTerminator()` is checking
|
// (when doing name lookup, for example). Notice: `RecvUntilTerminator()` is checking
|
||||||
|
|
|
@ -624,11 +624,11 @@ void BlockManager::CleanupBlockRevFiles() const
|
||||||
const std::string path = fs::PathToString(it->path().filename());
|
const std::string path = fs::PathToString(it->path().filename());
|
||||||
if (fs::is_regular_file(*it) &&
|
if (fs::is_regular_file(*it) &&
|
||||||
path.length() == 12 &&
|
path.length() == 12 &&
|
||||||
path.substr(8,4) == ".dat")
|
path.ends_with(".dat"))
|
||||||
{
|
{
|
||||||
if (path.substr(0, 3) == "blk") {
|
if (path.starts_with("blk")) {
|
||||||
mapBlockFiles[path.substr(3, 5)] = it->path();
|
mapBlockFiles[path.substr(3, 5)] = it->path();
|
||||||
} else if (path.substr(0, 3) == "rev") {
|
} else if (path.starts_with("rev")) {
|
||||||
remove(it->path());
|
remove(it->path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,13 @@ void RPCNestedTests::rpcNestedTests()
|
||||||
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter
|
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblock( getblock( getblock(getbestblockhash())[hash] )[hash], true)"); //4 level nesting with whitespace, filtering path and boolean parameter
|
||||||
|
|
||||||
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo");
|
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo");
|
||||||
QVERIFY(result.substr(0,1) == "{");
|
QVERIFY(result.starts_with("{"));
|
||||||
|
|
||||||
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo()");
|
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo()");
|
||||||
QVERIFY(result.substr(0,1) == "{");
|
QVERIFY(result.starts_with("{"));
|
||||||
|
|
||||||
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo "); //whitespace at the end will be tolerated
|
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo "); //whitespace at the end will be tolerated
|
||||||
QVERIFY(result.substr(0,1) == "{");
|
QVERIFY(result.starts_with("{"));
|
||||||
|
|
||||||
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo()[\"chain\"]"); //Quote path identifier are allowed, but look after a child containing the quotes in the key
|
RPCConsole::RPCExecuteCommandLine(m_node, result, "getblockchaininfo()[\"chain\"]"); //Quote path identifier are allowed, but look after a child containing the quotes in the key
|
||||||
QVERIFY(result == "null");
|
QVERIFY(result == "null");
|
||||||
|
|
|
@ -168,7 +168,7 @@ std::vector<T> Split(const std::span<const char>& sp, char sep)
|
||||||
|
|
||||||
[[nodiscard]] inline std::string_view RemovePrefixView(std::string_view str, std::string_view prefix)
|
[[nodiscard]] inline std::string_view RemovePrefixView(std::string_view str, std::string_view prefix)
|
||||||
{
|
{
|
||||||
if (str.substr(0, prefix.size()) == prefix) {
|
if (str.starts_with(prefix)) {
|
||||||
return str.substr(prefix.size());
|
return str.substr(prefix.size());
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
|
|
@ -559,7 +559,7 @@ RPCHelpMan importwallet()
|
||||||
fLabel = false;
|
fLabel = false;
|
||||||
if (vstr[nStr] == "reserve=1")
|
if (vstr[nStr] == "reserve=1")
|
||||||
fLabel = false;
|
fLabel = false;
|
||||||
if (vstr[nStr].substr(0,6) == "label=") {
|
if (vstr[nStr].starts_with("label=")) {
|
||||||
strLabel = DecodeDumpString(vstr[nStr].substr(6));
|
strLabel = DecodeDumpString(vstr[nStr].substr(6));
|
||||||
fLabel = true;
|
fLabel = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ std::unique_ptr<CZMQNotificationInterface> CZMQNotificationInterface::Create(std
|
||||||
const auto& factory = entry.second;
|
const auto& factory = entry.second;
|
||||||
for (std::string& address : gArgs.GetArgs(arg)) {
|
for (std::string& address : gArgs.GetArgs(arg)) {
|
||||||
// libzmq uses prefix "ipc://" for UNIX domain sockets
|
// libzmq uses prefix "ipc://" for UNIX domain sockets
|
||||||
if (address.substr(0, ADDR_PREFIX_UNIX.length()) == ADDR_PREFIX_UNIX) {
|
if (address.starts_with(ADDR_PREFIX_UNIX)) {
|
||||||
address.replace(0, ADDR_PREFIX_UNIX.length(), ADDR_PREFIX_IPC);
|
address.replace(0, ADDR_PREFIX_UNIX.length(), ADDR_PREFIX_IPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue