Merge pull request #5438

27df412 make all catch() arguments const (Philip Kaufmann)
This commit is contained in:
Wladimir J. van der Laan 2014-12-17 17:34:20 +01:00
commit 89802fe3ee
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6
24 changed files with 78 additions and 82 deletions

View File

@ -86,7 +86,7 @@ static bool AppInitRPC(int argc, char* argv[])
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
@ -206,7 +206,7 @@ int CommandLineRPC(int argc, char *argv[])
// Connection succeeded, no need to retry.
break;
}
catch (const CConnectionFailed& e) {
catch (const CConnectionFailed&) {
if (fWait)
MilliSleep(1000);
else
@ -214,10 +214,10 @@ int CommandLineRPC(int argc, char *argv[])
}
} while (fWait);
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
strPrint = string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
@ -240,7 +240,7 @@ int main(int argc, char* argv[])
if(!AppInitRPC(argc, argv))
return EXIT_FAILURE;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRPC()");
return EXIT_FAILURE;
} catch (...) {
@ -252,7 +252,7 @@ int main(int argc, char* argv[])
try {
ret = CommandLineRPC(argc, argv);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRPC()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRPC()");

View File

@ -586,10 +586,10 @@ static int CommandLineRawTx(int argc, char* argv[])
OutputTx(tx);
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
strPrint = string("error: ") + e.what();
nRet = EXIT_FAILURE;
}
@ -612,7 +612,7 @@ int main(int argc, char* argv[])
if(!AppInitRawTx(argc, argv))
return EXIT_FAILURE;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInitRawTx()");
return EXIT_FAILURE;
} catch (...) {
@ -624,7 +624,7 @@ int main(int argc, char* argv[])
try {
ret = CommandLineRawTx(argc, argv);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "CommandLineRawTx()");
} catch (...) {
PrintExceptionContinue(NULL, "CommandLineRawTx()");

View File

@ -97,7 +97,7 @@ bool AppInit(int argc, char* argv[])
try
{
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false;
}
@ -147,7 +147,7 @@ bool AppInit(int argc, char* argv[])
detectShutdownThread = new boost::thread(boost::bind(&DetectShutdownThread, &threadGroup));
fRet = AppInit2(threadGroup);
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "AppInit()");
} catch (...) {
PrintExceptionContinue(NULL, "AppInit()");

View File

@ -778,7 +778,7 @@ bool AppInit2(boost::thread_group& threadGroup)
try {
boost::filesystem::rename(pathDatabase, pathDatabaseBak);
LogPrintf("Moved old %s to %s. Retrying.\n", pathDatabase.string(), pathDatabaseBak.string());
} catch(boost::filesystem::filesystem_error &error) {
} catch (const boost::filesystem::filesystem_error&) {
// failure is ok (well, not really, but it's not worse than what we started with)
}
@ -931,7 +931,7 @@ bool AppInit2(boost::thread_group& threadGroup)
filesystem::create_hard_link(source, dest);
LogPrintf("Hardlinked %s -> %s\n", source.string(), dest.string());
linked = true;
} catch (filesystem::filesystem_error & e) {
} catch (const filesystem::filesystem_error& e) {
// Note: hardlink creation failing is not a disaster, it just means
// blocks will get re-downloaded from peers.
LogPrintf("Error hardlinking blk%04u.dat : %s\n", i, e.what());
@ -1008,7 +1008,7 @@ bool AppInit2(boost::thread_group& threadGroup)
strLoadError = _("Corrupted block database detected");
break;
}
} catch(std::exception &e) {
} catch (const std::exception& e) {
if (fDebug) LogPrintf("%s\n", e.what());
strLoadError = _("Error opening block database");
break;

View File

@ -1091,7 +1091,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
file >> header;
fseek(file.Get(), postx.nTxOffset, SEEK_CUR);
file >> txOut;
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
hashBlock = header.GetHash();
@ -1174,7 +1174,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
try {
filein >> block;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
@ -2598,7 +2598,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
return state.Abort("Failed to write block");
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
return error("AcceptBlock() : ReceivedBlockTransactions failed");
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
return state.Abort(std::string("System error: ") + e.what());
}
@ -2990,7 +2990,7 @@ bool InitBlockIndex() {
return error("LoadBlockIndex() : genesis block cannot be activated");
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
return error("LoadBlockIndex() : failed to initialize block database: %s", e.what());
}
}
@ -3090,11 +3090,11 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
mapBlocksUnknownParent.erase(it);
}
}
} catch (std::exception &e) {
} catch (const std::exception& e) {
LogPrintf("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
} catch(std::runtime_error &e) {
} catch (const std::runtime_error& e) {
AbortNode(std::string("System error: ") + e.what());
}
if (nLoaded > 0)
@ -4088,7 +4088,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
ss << ": hash " << hash.ToString();
}
LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
} catch (std::ios_base::failure& e) {
} catch (const std::ios_base::failure&) {
// Avoid feedback loops by preventing reject messages from triggering a new reject message.
LogPrint("net", "Unparseable reject message received\n");
}
@ -4192,7 +4192,7 @@ bool ProcessMessages(CNode* pfrom)
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
boost::this_thread::interruption_point();
}
catch (std::ios_base::failure& e)
catch (const std::ios_base::failure& e)
{
pfrom->PushMessage("reject", strCommand, REJECT_MALFORMED, string("error parsing message"));
if (strstr(e.what(), "end of data"))
@ -4210,10 +4210,10 @@ bool ProcessMessages(CNode* pfrom)
PrintExceptionContinue(&e, "ProcessMessages()");
}
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, "ProcessMessages()");
} catch (...) {
PrintExceptionContinue(NULL, "ProcessMessages()");
@ -4507,7 +4507,7 @@ bool CBlockUndo::ReadFromDisk(const CDiskBlockPos &pos, const uint256 &hashBlock
filein >> *this;
filein >> hashChecksum;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}

View File

@ -565,7 +565,7 @@ void static BitcoinMiner(CWallet *pwallet)
}
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("BitcoinMiner terminated\n");
throw;

View File

@ -1068,7 +1068,7 @@ void ThreadMapPort()
MilliSleep(20*60*1000); // Refresh every 20 minutes
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r);
@ -1854,7 +1854,7 @@ bool CAddrDB::Write(const CAddrMan& addr)
try {
fileout << ssPeers;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Serialize or I/O error - %s", __func__, e.what());
}
FileCommit(fileout.Get());
@ -1890,7 +1890,7 @@ bool CAddrDB::Read(CAddrMan& addr)
filein.read((char *)&vchData[0], dataSize);
filein >> hashIn;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
filein.fclose();
@ -1914,7 +1914,7 @@ bool CAddrDB::Read(CAddrMan& addr)
// de-serialize address data into one CAddrMan object
ssPeers >> addr;
}
catch (std::exception &e) {
catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}

View File

@ -173,7 +173,7 @@ private:
boost::thread_group threadGroup;
/// Pass fatal exception message to UI thread
void handleRunawayException(std::exception *e);
void handleRunawayException(const std::exception *e);
};
/** Main Bitcoin application object */
@ -240,7 +240,7 @@ BitcoinCore::BitcoinCore():
{
}
void BitcoinCore::handleRunawayException(std::exception *e)
void BitcoinCore::handleRunawayException(const std::exception *e)
{
PrintExceptionContinue(e, "Runaway exception");
emit runawayException(QString::fromStdString(strMiscWarning));
@ -260,7 +260,7 @@ void BitcoinCore::initialize()
StartDummyRPCThread();
}
emit initializeResult(rv);
} catch (std::exception& e) {
} catch (const std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
@ -277,7 +277,7 @@ void BitcoinCore::shutdown()
Shutdown();
qDebug() << __func__ << ": Shutdown finished";
emit shutdownResult(1);
} catch (std::exception& e) {
} catch (const std::exception& e) {
handleRunawayException(&e);
} catch (...) {
handleRunawayException(NULL);
@ -551,7 +551,7 @@ int main(int argc, char *argv[])
}
try {
ReadConfigFile(mapArgs, mapMultiArgs);
} catch(std::exception &e) {
} catch (const std::exception& e) {
QMessageBox::critical(0, QObject::tr("Bitcoin Core"),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
return false;
@ -628,7 +628,7 @@ int main(int argc, char *argv[])
app.exec();
app.requestShutdown();
app.exec();
} catch (std::exception& e) {
} catch (const std::exception& e) {
PrintExceptionContinue(&e, "Runaway exception");
app.handleRunawayException(QString::fromStdString(strMiscWarning));
} catch (...) {

View File

@ -95,7 +95,7 @@ void FreespaceChecker::check()
replyMessage = tr("Path already exists, and is not a directory.");
}
}
} catch(fs::filesystem_error &e)
} catch (const fs::filesystem_error&)
{
/* Parent directory does not exist or is not accessible */
replyStatus = ST_ERROR;
@ -180,7 +180,7 @@ void Intro::pickDataDirectory()
try {
TryCreateDirectory(GUIUtil::qstringToBoostPath(dataDir));
break;
} catch(fs::filesystem_error &e) {
} catch (const fs::filesystem_error&) {
QMessageBox::critical(0, tr("Bitcoin Core"),
tr("Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
/* fall through, back to choosing screen */

View File

@ -181,8 +181,7 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
}
// TODO: detect EV certificates and set merchant = business name instead of unfriendly NID_commonName ?
}
catch (SSLVerifyError& err)
{
catch (const SSLVerifyError& err) {
fResult = false;
qWarning() << "PaymentRequestPlus::getMerchant : SSL error: " << err.what();
}

View File

@ -180,7 +180,7 @@ void RPCExecutor::request(const QString &command)
emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint));
}
catch (json_spirit::Object& objError)
catch (const json_spirit::Object& objError)
{
try // Nice formatting for standard-format error
{
@ -188,12 +188,12 @@ void RPCExecutor::request(const QString &command)
std::string message = find_value(objError, "message").get_str();
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")");
}
catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message
catch (const std::runtime_error&) // raised when converting to invalid type, i.e. missing code or message
{ // Show raw JSON object
emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false)));
}
}
catch (std::exception& e)
catch (const std::exception& e)
{
emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what()));
}

View File

@ -307,7 +307,7 @@ bool HTTPReq_REST(AcceptedConnection* conn,
return uri_prefixes[i].handler(conn, strReq, mapHeaders, fRun);
}
}
} catch (RestErr& re) {
} catch (const RestErr& re) {
conn->stream() << HTTPReply(re.status, re.message + "\r\n", false, false, "text/plain") << std::flush;
return false;
}

View File

@ -122,8 +122,7 @@ public:
tcp::resolver::query query(server.c_str(), port.c_str());
endpoint_iterator = resolver.resolve(query);
#if BOOST_VERSION >= 104300
} catch(boost::system::system_error &e)
{
} catch (const boost::system::system_error&) {
// If we at first don't succeed, try blanket lookup (IPv4+IPv6 independent of configured interfaces)
tcp::resolver::query query(server.c_str(), port.c_str(), resolver_query_base::flags());
endpoint_iterator = resolver.resolve(query);

View File

@ -174,7 +174,7 @@ string CRPCTable::help(string strCommand) const
if (setDone.insert(pfn).second)
(*pfn)(params, true);
}
catch (std::exception& e)
catch (const std::exception& e)
{
// Help text is returned in an exception
string strHelp = string(e.what());
@ -676,7 +676,7 @@ void StartRPCThreads()
if(bBindAny && bindAddress == asio::ip::address_v6::any() && !v6_only_error)
break;
}
catch(boost::system::system_error &e)
catch (const boost::system::system_error& e)
{
LogPrintf("ERROR: Binding RPC on address %s port %i failed: %s\n", bindAddress.to_string(), endpoint.port(), e.what());
strerr = strprintf(_("An error occurred while setting up the RPC address %s port %u for listening: %s"), bindAddress.to_string(), endpoint.port(), e.what());
@ -842,11 +842,11 @@ static Object JSONRPCExecOne(const Value& req)
Value result = tableRPC.execute(jreq.strMethod, jreq.params);
rpc_result = JSONRPCReplyObj(result, Value::null, jreq.id);
}
catch (Object& objError)
catch (const Object& objError)
{
rpc_result = JSONRPCReplyObj(Value::null, objError, jreq.id);
}
catch (std::exception& e)
catch (const std::exception& e)
{
rpc_result = JSONRPCReplyObj(Value::null,
JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
@ -922,12 +922,12 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn,
conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush;
}
catch (Object& objError)
catch (const Object& objError)
{
ErrorReply(conn->stream(), objError, jreq.id);
return false;
}
catch (std::exception& e)
catch (const std::exception& e)
{
ErrorReply(conn->stream(), JSONRPCError(RPC_PARSE_ERROR, e.what()), jreq.id);
return false;
@ -1013,7 +1013,7 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
}
return result;
}
catch (std::exception& e)
catch (const std::exception& e)
{
throw JSONRPCError(RPC_MISC_ERROR, e.what());
}

View File

@ -79,7 +79,7 @@ int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned i
set_error(err, bitcoinconsensus_ERR_OK);
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), flags, SignatureChecker(tx, nIn), NULL);
} catch (std::exception &e) {
} catch (const std::exception&) {
return set_error(err, bitcoinconsensus_ERR_TX_DESERIALIZE); // Error deserializing
}
}

View File

@ -92,7 +92,7 @@ struct ReadAlerts
alerts.push_back(alert);
}
}
catch (std::exception) { }
catch (const std::exception&) { }
}
~ReadAlerts() { }

View File

@ -39,8 +39,7 @@ Value CallRPC(string args)
Value result = (*method)(params, false);
return result;
}
catch (Object& objError)
{
catch (const Object& objError) {
throw runtime_error(find_value(objError, "message").get_str());
}
}

View File

@ -129,7 +129,7 @@ bool CCoinsViewDB::GetStats(CCoinsStats &stats) const {
ss << VARINT(0);
}
pcursor->Next();
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}
@ -218,7 +218,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
} else {
break; // if shutdown requested or finished loading block index
}
} catch (std::exception &e) {
} catch (const std::exception& e) {
return error("%s : Deserialize or I/O error - %s", __func__, e.what());
}
}

View File

@ -346,7 +346,7 @@ bool SoftSetBoolArg(const std::string& strArg, bool fValue)
return SoftSetArg(strArg, std::string("0"));
}
static std::string FormatException(std::exception* pex, const char* pszThread)
static std::string FormatException(const std::exception* pex, const char* pszThread)
{
#ifdef WIN32
char pszModule[MAX_PATH] = "";
@ -362,7 +362,7 @@ static std::string FormatException(std::exception* pex, const char* pszThread)
"UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread);
}
void PrintExceptionContinue(std::exception* pex, const char* pszThread)
void PrintExceptionContinue(const std::exception* pex, const char* pszThread)
{
std::string message = FormatException(pex, pszThread);
LogPrintf("\n\n************************\n%s\n", message);
@ -514,7 +514,7 @@ bool TryCreateDirectory(const boost::filesystem::path& p)
try
{
return boost::filesystem::create_directory(p);
} catch (boost::filesystem::filesystem_error) {
} catch (const boost::filesystem::filesystem_error&) {
if (!boost::filesystem::exists(p) || !boost::filesystem::is_directory(p))
throw;
}
@ -721,8 +721,7 @@ void SetupEnvironment()
#else // boost filesystem v2
std::locale(); // Raises runtime error if current locale is invalid
#endif
} catch(std::runtime_error &e)
{
} catch (const std::runtime_error&) {
setenv("LC_ALL", "C", 1); // Force C locale
}
#endif

View File

@ -84,7 +84,7 @@ static inline bool error(const char* format)
return false;
}
void PrintExceptionContinue(std::exception* pex, const char* pszThread);
void PrintExceptionContinue(const std::exception *pex, const char* pszThread);
void ParseParameters(int argc, const char*const argv[]);
void FileCommit(FILE *fileout);
bool TruncateFile(FILE *file, unsigned int length);
@ -186,12 +186,12 @@ template <typename Callable> void LoopForever(const char* name, Callable func,
func();
}
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("%s thread stop\n", name);
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, name);
throw;
}
@ -214,12 +214,12 @@ template <typename Callable> void TraceThread(const char* name, Callable func)
func();
LogPrintf("%s thread exit\n", name);
}
catch (boost::thread_interrupted)
catch (const boost::thread_interrupted&)
{
LogPrintf("%s thread interrupt\n", name);
throw;
}
catch (std::exception& e) {
catch (const std::exception& e) {
PrintExceptionContinue(&e, name);
throw;
}

View File

@ -664,7 +664,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
}
pcursor->close();
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (...) {
@ -757,7 +757,7 @@ DBErrors CWalletDB::FindWalletTx(CWallet* pwallet, vector<uint256>& vTxHash, vec
}
pcursor->close();
}
catch (boost::thread_interrupted) {
catch (const boost::thread_interrupted&) {
throw;
}
catch (...) {