Skip to content

Commit db2f83e

Browse files
committed
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
2 parents c95832d + b296bf1 commit db2f83e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/bitcoind.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ bool AppInit(int argc, char* argv[])
120120
for (int i = 1; i < argc; i++) {
121121
if (!IsSwitchChar(argv[i][0])) {
122122
fprintf(stderr, "Error: Command line contains unexpected token '%s', see bitcoind -h for a list of options.\n", argv[i]);
123-
exit(EXIT_FAILURE);
123+
return false;
124124
}
125125
}
126126

@@ -132,17 +132,17 @@ bool AppInit(int argc, char* argv[])
132132
if (!AppInitBasicSetup())
133133
{
134134
// InitError will have been called with detailed error, which ends up on console
135-
exit(EXIT_FAILURE);
135+
return false;
136136
}
137137
if (!AppInitParameterInteraction())
138138
{
139139
// InitError will have been called with detailed error, which ends up on console
140-
exit(EXIT_FAILURE);
140+
return false;
141141
}
142142
if (!AppInitSanityChecks())
143143
{
144144
// InitError will have been called with detailed error, which ends up on console
145-
exit(EXIT_FAILURE);
145+
return false;
146146
}
147147
if (gArgs.GetBoolArg("-daemon", false))
148148
{
@@ -163,7 +163,7 @@ bool AppInit(int argc, char* argv[])
163163
if (!AppInitLockDataDirectory())
164164
{
165165
// If locking the data directory failed, exit immediately
166-
exit(EXIT_FAILURE);
166+
return false;
167167
}
168168
fRet = AppInitMain(threadGroup, scheduler);
169169
}

0 commit comments

Comments
 (0)