mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Merge #11511: [Init] Remove redundant exit(EXIT_FAILURE) instances and replace with return false
b296bf1
Init: Remove redundant exit(EXIT_FAILURE) instances and replace with return false (donaloconnor)
Pull request description:
While reviewing the bitcoin code I noticed that there are a few exit(EXIT_FAILURE) at various places in the AppInit function.
This function returns to main() which will return/exit with EXIT_FAILURE so returning false instead of an explicit exit(EXIT_FAILURE) seems to be cleaner.
This PR attempts to make things a bit more consistent.
There is a subtle difference between exit() and return from main in that the exit() will not clean up any local vars but I don't think this makes a difference in this case. Using exit() might even lead to bugs in the future where the dtor of local objects are expected to be called.
Tree-SHA512: 7d104c3a752b4e7d7bc2382ef7e62543462988f1bbf13dd4077fbeff5399729b76c71a4352556f188b8d306604232477466f5bb827b58a6f3f6273f2370e1faa
This commit is contained in:
parent
ce381d0826
commit
5f7eebec51
@ -133,7 +133,7 @@ bool AppInit(int argc, char* argv[])
|
|||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (!IsSwitchChar(argv[i][0])) {
|
if (!IsSwitchChar(argv[i][0])) {
|
||||||
fprintf(stderr, "Error: Command line contains unexpected token '%s', see dashd -h for a list of options.\n", argv[i]);
|
fprintf(stderr, "Error: Command line contains unexpected token '%s', see dashd -h for a list of options.\n", argv[i]);
|
||||||
exit(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,17 +145,17 @@ bool AppInit(int argc, char* argv[])
|
|||||||
if (!AppInitBasicSetup())
|
if (!AppInitBasicSetup())
|
||||||
{
|
{
|
||||||
// InitError will have been called with detailed error, which ends up on console
|
// InitError will have been called with detailed error, which ends up on console
|
||||||
exit(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
if (!AppInitParameterInteraction())
|
if (!AppInitParameterInteraction())
|
||||||
{
|
{
|
||||||
// InitError will have been called with detailed error, which ends up on console
|
// InitError will have been called with detailed error, which ends up on console
|
||||||
exit(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
if (!AppInitSanityChecks())
|
if (!AppInitSanityChecks())
|
||||||
{
|
{
|
||||||
// InitError will have been called with detailed error, which ends up on console
|
// InitError will have been called with detailed error, which ends up on console
|
||||||
exit(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
if (gArgs.GetBoolArg("-daemon", false))
|
if (gArgs.GetBoolArg("-daemon", false))
|
||||||
{
|
{
|
||||||
@ -176,7 +176,7 @@ bool AppInit(int argc, char* argv[])
|
|||||||
if (!AppInitLockDataDirectory())
|
if (!AppInitLockDataDirectory())
|
||||||
{
|
{
|
||||||
// If locking the data directory failed, exit immediately
|
// If locking the data directory failed, exit immediately
|
||||||
exit(EXIT_FAILURE);
|
return false;
|
||||||
}
|
}
|
||||||
fRet = AppInitMain(threadGroup, scheduler);
|
fRet = AppInitMain(threadGroup, scheduler);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
Loading…
Reference in New Issue
Block a user