diff --git a/src/bench/bench_bitcoin.cpp b/src/bench/bench_bitcoin.cpp --- a/src/bench/bench_bitcoin.cpp +++ b/src/bench/bench_bitcoin.cpp @@ -72,7 +72,7 @@ std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { tfm::format(std::cerr, "Error parsing command line arguments: %s\n", - error.c_str()); + error); return EXIT_FAILURE; } @@ -89,7 +89,7 @@ double scaling_factor; if (!ParseDouble(scaling_str, &scaling_factor)) { tfm::format(std::cerr, "Error parsing scaling factor as double: %s\n", - scaling_str.c_str()); + scaling_str); return EXIT_FAILURE; } diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -154,7 +154,7 @@ std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { tfm::format(std::cerr, "Error parsing command line arguments: %s\n", - error.c_str()); + error); return EXIT_FAILURE; } if (argc < 2 || HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { @@ -175,7 +175,7 @@ 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; @@ -185,12 +185,11 @@ if (!CheckDataDirOption()) { tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", - gArgs.GetArg("-datadir", "").c_str()); + 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 @@ -478,8 +477,7 @@ "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())); + .string())); } else { throw std::runtime_error( "Authorization failed: Incorrect rpcuser or rpcpassword"); @@ -615,8 +613,7 @@ } 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; } diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -110,7 +110,7 @@ std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { tfm::format(std::cerr, "Error parsing command line arguments: %s\n", - error.c_str()); + error); return EXIT_FAILURE; } @@ -136,7 +136,8 @@ "hex-encoded bitcoin transaction\n" + "\n"; strUsage += 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"); @@ -763,20 +764,20 @@ TxToUniv(tx, uint256(), entry); std::string jsonOutput = entry.write(4); - tfm::format(std::cout, "%s\n", jsonOutput.c_str()); + tfm::format(std::cout, "%s\n", jsonOutput); } static void OutputTxHash(const CTransaction &tx) { // the hex-encoded transaction id. std::string strHexHash = tx.GetId().GetHex(); - tfm::format(std::cout, "%s\n", strHexHash.c_str()); + tfm::format(std::cout, "%s\n", strHexHash); } static void OutputTxHex(const CTransaction &tx) { std::string strHex = EncodeHexTx(tx); - tfm::format(std::cout, "%s\n", strHex.c_str()); + tfm::format(std::cout, "%s\n", strHex); } static void OutputTx(const CTransaction &tx) { @@ -871,8 +872,7 @@ } 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; diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -51,7 +51,7 @@ std::string error_message; if (!gArgs.ParseParameters(argc, argv, error_message)) { tfm::format(std::cerr, "Error parsing command line arguments: %s\n", - error_message.c_str()); + error_message); return false; } if (argc < 2 || HelpRequested(gArgs)) { @@ -67,7 +67,7 @@ "Usage:\n" + " bitcoin-wallet [options] \n\n" + gArgs.GetHelpMessage(); - tfm::format(std::cout, "%s", usage.c_str()); + tfm::format(std::cout, "%s", usage); return false; } @@ -78,7 +78,7 @@ if (!CheckDataDirOption()) { tfm::format(std::cerr, "Error: Specified data directory \"%s\" does not exist.\n", - gArgs.GetArg("-datadir", "").c_str()); + gArgs.GetArg("-datadir", "")); return false; } // Check for -testnet or -regtest parameter (Params() calls are only valid @@ -114,7 +114,7 @@ tfm::format(std::cerr, "Error: two methods provided (%s and %s). Only one " "method should be provided.\n", - method.c_str(), argv[i]); + method, argv[i]); return EXIT_FAILURE; } method = argv[i]; diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -100,7 +100,7 @@ strUsage += "\n" + gArgs.GetHelpMessage(); } - tfm::format(std::cout, "%s", strUsage.c_str()); + tfm::format(std::cout, "%s", strUsage); return true; } diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -1613,7 +1613,7 @@ if (!fs::is_directory(GetBlocksDir())) { return InitError( strprintf(_("Specified blocks directory \"%s\" does not exist."), - gArgs.GetArg("-blocksdir", "").c_str())); + gArgs.GetArg("-blocksdir", ""))); } // if using block pruning, then disallow txindex diff --git a/src/net.cpp b/src/net.cpp --- a/src/net.cpp +++ b/src/net.cpp @@ -1432,7 +1432,7 @@ CNetAddr resolved; if (LookupHost(externalIPAddress, resolved, false)) { LogPrintf("UPnP: ExternalIPAddress = %s\n", - resolved.ToString().c_str()); + resolved.ToString()); AddLocal(resolved, LOCAL_UPNP); } } else { @@ -2712,7 +2712,7 @@ size_t nMessageSize = msg.data.size(); size_t nTotalSize = nMessageSize + CMessageHeader::HEADER_SIZE; LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", - SanitizeString(msg.command.c_str()), nMessageSize, pnode->GetId()); + SanitizeString(msg.command), nMessageSize, pnode->GetId()); std::vector serializedHeader; serializedHeader.reserve(CMessageHeader::HEADER_SIZE); diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1158,12 +1158,12 @@ LogPrintf( "%s: %s peer=%d (%d -> %d) reason: %s BAN THRESHOLD EXCEEDED\n", __func__, state->name, pnode, state->nMisbehavior - howmuch, - state->nMisbehavior, reason.c_str()); + state->nMisbehavior, reason); state->fShouldBan = true; } else { LogPrintf("%s: %s peer=%d (%d -> %d) reason: %s\n", __func__, state->name, pnode, state->nMisbehavior - howmuch, - state->nMisbehavior, reason.c_str()); + state->nMisbehavior, reason); } } @@ -2284,7 +2284,7 @@ LogPrint(BCLog::NET, "receive version message: [%s] %s: version %d, blocks=%d, " "us=%s, peer=%d%s\n", - pfrom->addr.ToString().c_str(), cleanSubVer, pfrom->nVersion, + pfrom->addr.ToString(), cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->GetId(), remoteAddr); diff --git a/src/noui.cpp b/src/noui.cpp --- a/src/noui.cpp +++ b/src/noui.cpp @@ -45,7 +45,7 @@ if (!fSecure) { LogPrintf("%s: %s\n", strCaption, message); } - tfm::format(std::cerr, "%s: %s\n", strCaption.c_str(), message.c_str()); + tfm::format(std::cerr, "%s%s\n", strCaption, message); return false; } diff --git a/src/seeder/bitcoin.cpp b/src/seeder/bitcoin.cpp --- a/src/seeder/bitcoin.cpp +++ b/src/seeder/bitcoin.cpp @@ -26,7 +26,7 @@ nHeaderStart = vSend.size(); vSend << CMessageHeader(netMagic, pszCommand, 0); nMessageStart = vSend.size(); - // tfm::format(std::cout, "%s: SEND %s\n", ToString(you).c_str(), + // tfm::format(std::cout, "%s: SEND %s\n", ToString(you), // pszCommand); } @@ -93,8 +93,8 @@ PeerMessagingState CSeederNode::ProcessMessage(std::string strCommand, CDataStream &recv) { - // tfm::format(std::cout, "%s: RECV %s\n", ToString(you).c_str(), - // strCommand.c_str()); + // tfm::format(std::cout, "%s: RECV %s\n", ToString(you), + // strCommand); if (strCommand == "version") { int64_t nTime; CAddress addrMe; @@ -115,7 +115,7 @@ if (strCommand == "verack") { vRecv.SetVersion(std::min(nVersion, PROTOCOL_VERSION)); - // tfm::format(std::cout, "\n%s: version %i\n", ToString(you).c_str(), + // tfm::format(std::cout, "\n%s: version %i\n", ToString(you), // nVersion); if (vAddr) { BeginMessage("getaddr"); @@ -131,7 +131,7 @@ std::vector vAddrNew; recv >> vAddrNew; // tfm::format(std::cout, "%s: got %i addresses\n", - // ToString(you).c_str(), + // ToString(you), // (int)vAddrNew.size()); int64_t now = time(nullptr); std::vector::iterator it = vAddrNew.begin(); @@ -143,8 +143,8 @@ while (it != vAddrNew.end()) { CAddress &addr = *it; // tfm::format(std::cout, "%s: got address %s\n", - // ToString(you).c_str(), - // addr.ToString().c_str(), (int)(vAddr->size())); + // ToString(you), + // addr.ToString(), (int)(vAddr->size())); it++; if (addr.nTime <= 100000000 || addr.nTime > now + 600) { addr.nTime = now - 5 * 86400; @@ -153,8 +153,8 @@ vAddr->push_back(addr); } // tfm::format(std::cout, "%s: added address %s (#%i)\n", - // ToString(you).c_str(), - // addr.ToString().c_str(), (int)(vAddr->size())); + // ToString(you), + // addr.ToString(), (int)(vAddr->size())); if (vAddr->size() > ADDR_SOFT_CAP) { doneAfter = 1; return PeerMessagingState::Finished; @@ -189,7 +189,7 @@ vRecv >> hdr; if (!hdr.IsValidWithoutConfig(netMagic)) { // tfm::format(std::cout, "%s: BAD (invalid header)\n", - // ToString(you).c_str()); + // ToString(you)); ban = 100000; return true; } @@ -197,7 +197,7 @@ unsigned int nMessageSize = hdr.nMessageSize; if (nMessageSize > MAX_SIZE) { // tfm::format(std::cout, "%s: BAD (message too large)\n", - // ToString(you).c_str()); + // ToString(you)); ban = 100000; return true; } @@ -219,8 +219,8 @@ return true; } // tfm::format(std::cout, "%s: done processing %s\n", - // ToString(you).c_str(), - // strCommand.c_str()); + // ToString(you), + // strCommand); } while (1); return false; } @@ -265,7 +265,7 @@ if (!connected) { // tfm::format(std::cout, "Cannot connect to %s\n", - // ToString(you).c_str()); + // ToString(you)); CloseSocket(sock); return false; } @@ -308,12 +308,12 @@ } else if (nBytes == 0) { // tfm::format(std::cout, "%s: BAD (connection closed // prematurely)\n", - // ToString(you).c_str()); + // ToString(you)); res = false; break; } else { // tfm::format(std::cout, "%s: BAD (connection error)\n", - // ToString(you).c_str()); + // ToString(you)); res = false; break; } diff --git a/src/seeder/db.cpp b/src/seeder/db.cpp --- a/src/seeder/db.cpp +++ b/src/seeder/db.cpp @@ -30,7 +30,7 @@ } // tfm::format(std::cout, "%s: got %s result: success=%i/%i; // 2H:%.2f%%-%.2f%%(%.2f) 8H:%.2f%%-%.2f%%(%.2f) 1D:%.2f%%-%.2f%%(%.2f) - // 1W:%.2f%%-%.2f%%(%.2f) \n", ToString(ip).c_str(), good ? "good" : "bad", + // 1W:%.2f%%-%.2f%%(%.2f) \n", ToString(ip), good ? "good" : "bad", // success, total, 100.0 * stat2H.reliability, 100.0 * (stat2H.reliability // + 1.0 - stat2H.weight), stat2H.count, 100.0 * stat8H.reliability, 100.0 // * (stat8H.reliability + 1.0 - stat8H.weight), stat8H.count, 100.0 * @@ -100,7 +100,7 @@ if (info.IsReliable() && goodId.count(id) == 0) { goodId.insert(id); // tfm::format(std::cout, "%s: good; %i good nodes now\n", - // ToString(addr).c_str(), (int)goodId.size()); + // ToString(addr), (int)goodId.size()); } nDirty++; ourId.push_back(id); @@ -117,14 +117,14 @@ uint32_t now = time(nullptr); int ter = info.GetBanTime(); if (ter) { - // tfm::format(std::cout, "%s: terrible\n", ToString(addr).c_str()); + // tfm::format(std::cout, "%s: terrible\n", ToString(addr)); if (ban < ter) { ban = ter; } } if (ban > 0) { // tfm::format(std::cout, "%s: ban for %i seconds\n", - // ToString(addr).c_str(), ban); + // ToString(addr), ban); banned[info.ip] = ban + now; ipToId.erase(info.ip); goodId.erase(id); @@ -133,7 +133,7 @@ if (/*!info.IsReliable() && */ goodId.count(id) == 1) { goodId.erase(id); // tfm::format(std::cout, "%s: not good; %i good nodes left\n", - // ToString(addr).c_str(), (int)goodId.size()); + // ToString(addr), (int)goodId.size()); } ourId.push_back(id); } @@ -159,7 +159,7 @@ ai.lastTry = addr.nTime; ai.services |= addr.nServices; // tfm::format(std::cout, "%s: updated\n", - // ToString(addr).c_str()); + // ToString(addr)); } if (force) { ai.ignoreTill = 0; @@ -177,7 +177,7 @@ int id = nId++; idToInfo[id] = ai; ipToId[ipp] = id; - // tfm::format(std::cout, "%s: added\n", ToString(ipp).c_str(), + // tfm::format(std::cout, "%s: added\n", ToString(ipp), // ipToId[ipp]); unkId.insert(id); nDirty++; diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp --- a/src/seeder/main.cpp +++ b/src/seeder/main.cpp @@ -64,7 +64,7 @@ std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { tfm::format(std::cerr, "Error parsing command line arguments: %s\n", - error.c_str()); + error); return EXIT_FAILURE; } if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { @@ -77,7 +77,7 @@ gArgs.GetHelpMessage(); } - tfm::format(std::cout, "%s", strUsage.c_str()); + tfm::format(std::cout, "%s", strUsage); return EXIT_SUCCESS; } @@ -201,7 +201,7 @@ res.nClientV = node.GetClientVersion(); res.strClientV = node.GetClientSubVersion(); res.nHeight = node.GetStartingHeight(); - // tfm::format(std::cout, "%s: %s!!!\n", cip.ToString().c_str(), + // tfm::format(std::cout, "%s: %s!!!\n", cip.ToString(), // ret ? "GOOD" : "BAD"); res.fGood = ret; } catch (std::ios_base::failure &e) { @@ -402,11 +402,11 @@ "%-47s %4d %11" PRId64 " %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64 " %5i \"%s\"\n", - rep.ip.ToString().c_str(), (int)rep.fGood, rep.lastSuccess, + rep.ip.ToString(), (int)rep.fGood, rep.lastSuccess, 100.0 * rep.uptime[0], 100.0 * rep.uptime[1], 100.0 * rep.uptime[2], 100.0 * rep.uptime[3], 100.0 * rep.uptime[4], rep.blocks, rep.services, - rep.clientVersion, rep.clientSubVersion.c_str()); + rep.clientVersion, rep.clientSubVersion); stat[0] += rep.uptime[0]; stat[1] += rep.uptime[1]; stat[2] += rep.uptime[2]; @@ -499,7 +499,7 @@ CService service(LookupNumeric(opts.tor.c_str(), 9050)); if (service.IsValid()) { tfm::format(std::cout, "Using Tor proxy at %s\n", - service.ToStringIPPort().c_str()); + service.ToStringIPPort()); SetProxy(NET_ONION, proxyType(service)); } } @@ -507,7 +507,7 @@ CService service(LookupNumeric(opts.ipv4_proxy.c_str(), 9050)); if (service.IsValid()) { tfm::format(std::cout, "Using IPv4 proxy at %s\n", - service.ToStringIPPort().c_str()); + service.ToStringIPPort()); SetProxy(NET_IPV4, proxyType(service)); } } @@ -515,12 +515,12 @@ CService service(LookupNumeric(opts.ipv6_proxy.c_str(), 9050)); if (service.IsValid()) { tfm::format(std::cout, "Using IPv6 proxy at %s\n", - service.ToStringIPPort().c_str()); + service.ToStringIPPort()); SetProxy(NET_IPV6, proxyType(service)); } } bool fDNS = true; - tfm::format(std::cout, "Using %s.\n", gArgs.GetChainName().c_str()); + tfm::format(std::cout, "Using %s.\n", gArgs.GetChainName()); netMagic = Params().NetMagic(); if (opts.ns.empty()) { tfm::format(std::cout, "No nameserver set. Not starting DNS server.\n"); @@ -551,9 +551,9 @@ } pthread_t threadDns, threadSeed, threadDump, threadStats; if (fDNS) { - tfm::format( - std::cout, "Starting %i DNS threads for %s on %s (port %i)...", - opts.nDnsThreads, opts.host.c_str(), opts.ns.c_str(), opts.nPort); + tfm::format(std::cout, + "Starting %i DNS threads for %s on %s (port %i)...", + opts.nDnsThreads, opts.host, opts.ns, opts.nPort); dnsThread.clear(); for (int i = 0; i < opts.nDnsThreads; i++) { dnsThread.push_back(new CDnsThread(&opts, i)); diff --git a/src/sync.cpp b/src/sync.cpp --- a/src/sync.cpp +++ b/src/sync.cpp @@ -170,7 +170,7 @@ } tfm::format(std::cerr, "Assertion failed: lock %s not held in %s:%i; locks held:\n%s", - pszName, pszFile, nLine, LocksHeld().c_str()); + pszName, pszFile, nLine, LocksHeld()); abort(); } @@ -181,7 +181,7 @@ tfm::format( std::cerr, "Assertion failed: lock %s held in %s:%i; locks held:\n%s", - pszName, pszFile, nLine, LocksHeld().c_str()); + pszName, pszFile, nLine, LocksHeld()); abort(); } } diff --git a/src/util/system.cpp b/src/util/system.cpp --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -641,8 +641,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() { diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -38,7 +38,7 @@ bool first_run = true; DBErrors load_wallet_ret = wallet_instance->LoadWallet(first_run); if (load_wallet_ret != DBErrors::LOAD_OK) { - tfm::format(std::cerr, "Error creating %s", name.c_str()); + tfm::format(std::cerr, "Error creating %s", name); return nullptr; } @@ -74,27 +74,25 @@ tfm::format( std::cerr, "Error loading %s. Is wallet being used by another process?\n", - name.c_str()); + name); return nullptr; } if (load_wallet_ret != DBErrors::LOAD_OK) { wallet_instance = nullptr; if (load_wallet_ret == DBErrors::CORRUPT) { - tfm::format(std::cerr, "Error loading %s: Wallet corrupted", - name.c_str()); + tfm::format(std::cerr, "Error loading %s: Wallet corrupted", name); return nullptr; } else if (load_wallet_ret == DBErrors::NONCRITICAL_ERROR) { 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()); + "Error reading %s! All keys read correctly, but transaction " + "data or address book entries might be missing or incorrect.", + name); } else if (load_wallet_ret == DBErrors::TOO_NEW) { tfm::format(std::cerr, "Error loading %s: Wallet requires newer version of %s", - name.c_str(), PACKAGE_NAME); + name, PACKAGE_NAME); return nullptr; } else if (load_wallet_ret == DBErrors::NEED_REWRITE) { tfm::format(std::cerr, @@ -102,7 +100,7 @@ PACKAGE_NAME); return nullptr; } else { - tfm::format(std::cerr, "Error loading %s", name.c_str()); + tfm::format(std::cerr, "Error loading %s", name); return nullptr; } } @@ -139,8 +137,7 @@ } } else if (command == "info") { if (!fs::exists(path)) { - tfm::format(std::cerr, "Error: no wallet file at %s\n", - name.c_str()); + tfm::format(std::cerr, "Error: no wallet file at %s\n", name); return false; } std::string error; @@ -148,7 +145,7 @@ tfm::format( std::cerr, "Error loading %s. Is wallet being used by other process?\n", - name.c_str()); + name); return false; } std::shared_ptr wallet_instance = LoadWallet(name, path); @@ -158,7 +155,7 @@ WalletShowInfo(wallet_instance.get()); wallet_instance->Flush(); } else { - tfm::format(std::cerr, "Invalid command: %s\n", command.c_str()); + tfm::format(std::cerr, "Invalid command: %s\n", command); return false; }