Skip to content

Commit

Permalink
Every main()/exit() should return/use one of EXIT_ codes instead of m…
Browse files Browse the repository at this point in the history
…agic numbers
  • Loading branch information
UdjinM6 committed Nov 7, 2016
1 parent bd0de13 commit 4441018
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/bitcoind.cpp
Expand Up @@ -126,7 +126,7 @@ bool AppInit(int argc, char* argv[])
if (fCommandLine)
{
fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n");
exit(1);
exit(EXIT_FAILURE);
}
if (GetBoolArg("-daemon", false))
{
Expand Down Expand Up @@ -177,5 +177,5 @@ int main(int argc, char* argv[])
// Connect bitcoind signal handlers
noui_connect();

return (AppInit(argc, argv) ? 0 : 1);
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
}
14 changes: 7 additions & 7 deletions src/qt/bitcoin.cpp
Expand Up @@ -496,7 +496,7 @@ void BitcoinApplication::shutdownResult(int retval)
void BitcoinApplication::handleRunawayException(const QString &message)
{
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message);
::exit(1);
::exit(EXIT_FAILURE);
}

WId BitcoinApplication::getMainWinId() const
Expand Down Expand Up @@ -573,28 +573,28 @@ int main(int argc, char *argv[])
{
HelpMessageDialog help(NULL, mapArgs.count("-version"));
help.showOrPrint();
return 0;
return EXIT_SUCCESS;
}

/// 5. Now that settings and translations are available, ask user for data directory
// User language is set up: pick a data directory
if (!Intro::pickDataDirectory())
return 0;
return EXIT_SUCCESS;

/// 6. Determine availability of data directory and parse bitcoin.conf
/// - Do not call GetDataDir(true) before this step finishes
if (!boost::filesystem::is_directory(GetDataDir(false)))
{
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"])));
return 1;
return EXIT_FAILURE;
}
try {
ReadConfigFile(GetArg("-conf", BITCOIN_CONF_FILENAME), mapArgs, mapMultiArgs);
} catch (const std::exception& e) {
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME),
QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
return 1;
return EXIT_FAILURE;
}

/// 7. Determine network (and switch to network specific options)
Expand All @@ -608,7 +608,7 @@ int main(int argc, char *argv[])
SelectParams(ChainNameFromCommandLine());
} catch(std::exception &e) {
QMessageBox::critical(0, QObject::tr(PACKAGE_NAME), QObject::tr("Error: %1").arg(e.what()));
return 1;
return EXIT_FAILURE;
}
#ifdef ENABLE_WALLET
// Parse URIs on command line -- this can affect Params()
Expand All @@ -630,7 +630,7 @@ int main(int argc, char *argv[])
// - Do this after creating app and setting up translations, so errors are
// translated properly.
if (PaymentServer::ipcSendCommandLine())
exit(0);
exit(EXIT_SUCCESS);

// Start up the payment server early, too, so impatient users that click on
// bitcoin: links repeatedly have their payment requests routed to this process:
Expand Down

0 comments on commit 4441018

Please sign in to comment.