Skip to content

Commit 4441018

Browse files
committed
Every main()/exit() should return/use one of EXIT_ codes instead of magic numbers
1 parent bd0de13 commit 4441018

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/bitcoind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ bool AppInit(int argc, char* argv[])
126126
if (fCommandLine)
127127
{
128128
fprintf(stderr, "Error: There is no RPC client functionality in bitcoind anymore. Use the bitcoin-cli utility instead.\n");
129-
exit(1);
129+
exit(EXIT_FAILURE);
130130
}
131131
if (GetBoolArg("-daemon", false))
132132
{
@@ -177,5 +177,5 @@ int main(int argc, char* argv[])
177177
// Connect bitcoind signal handlers
178178
noui_connect();
179179

180-
return (AppInit(argc, argv) ? 0 : 1);
180+
return (AppInit(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE);
181181
}

src/qt/bitcoin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void BitcoinApplication::shutdownResult(int retval)
496496
void BitcoinApplication::handleRunawayException(const QString &message)
497497
{
498498
QMessageBox::critical(0, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. Bitcoin can no longer continue safely and will quit.") + QString("\n\n") + message);
499-
::exit(1);
499+
::exit(EXIT_FAILURE);
500500
}
501501

502502
WId BitcoinApplication::getMainWinId() const
@@ -573,28 +573,28 @@ int main(int argc, char *argv[])
573573
{
574574
HelpMessageDialog help(NULL, mapArgs.count("-version"));
575575
help.showOrPrint();
576-
return 0;
576+
return EXIT_SUCCESS;
577577
}
578578

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

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

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

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

0 commit comments

Comments
 (0)