Skip to content

Conversation

laanwj
Copy link
Member

@laanwj laanwj commented May 30, 2018

Return 1 from main() on error, not the bool false (introduced in #13112). This is the correct value to return on error, and also shuts up a clang warning.

@laanwj laanwj added the Tests label May 30, 2018
Copy link
Contributor

@jb55 jb55 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e

Copy link
Contributor

@ken2812221 ken2812221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e

@sipa
Copy link
Member

sipa commented May 30, 2018

ACK. Also, why does that function not have a return statement at the end?

@maflcko
Copy link
Member

maflcko commented May 30, 2018

Concept ACK. Similar to qt's main we could return EXIT_SUCCESS at the end or EXIT_FAILURE on an init error.

@promag
Copy link
Contributor

promag commented May 30, 2018

utACK.

@sipa fyi https://stackoverflow.com/a/10079465

From the C Standard:
(C99, 6.9.1p12) "If the } that terminates a function is reached, and the value of the function call is used by the caller, the behavior is undefined."
The main function is an exception to this rule as if the } is reached in main it is equivalent as if there was a return 0; statement.

@laanwj add return at end?

@achow101
Copy link
Member

utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e

@@ -46,7 +46,7 @@ main(int argc, char** argv)
std::string error;
if (!gArgs.ParseParameters(argc, argv, error)) {
fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str());
return false;
return 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXIT_FAILURE would be more explicit.

Copy link
Member Author

@laanwj laanwj May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it? I'm not sure. I've always found those constants quite useless.
I prefer using the explicit status codes, it is more flexible if want to use other codes than just 0 and 1 in the future.

Edit: I'll do it, just only for consistency with the other files.

@Empact
Copy link
Contributor

Empact commented May 30, 2018

Would prefer that all returns be updated, including adding an explicit final return (which is currently implicitly 0).
http://en.cppreference.com/w/cpp/language/return

@laanwj laanwj force-pushed the 2017_05_bench_warning branch from cd2e257 to 1b612c0 Compare May 31, 2018 05:19
Return `EXIT_SUCCESS` from `main()` on error, not the bool `false`
(introduced in bitcoin#13112). This is the correct value to return on error,
and also shuts up a clang warning.

Also add a final return for clarity.
@laanwj laanwj force-pushed the 2017_05_bench_warning branch from 1b612c0 to 493a166 Compare May 31, 2018 05:30
@laanwj
Copy link
Member Author

laanwj commented May 31, 2018

Seemingly, I've been dragged along into updating the function for the latest fashion standards. Please re-review!

@fanquake
Copy link
Member

utACK 493a166

@promag
Copy link
Contributor

promag commented May 31, 2018

utACK 493a166.

@maflcko maflcko merged commit 493a166 into bitcoin:master May 31, 2018
maflcko pushed a commit that referenced this pull request May 31, 2018
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in #13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 19, 2021
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in bitcoin#13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 24, 2021
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in bitcoin#13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 26, 2021
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in bitcoin#13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 26, 2021
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in bitcoin#13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 28, 2021
493a166 bench: Don't return a bool from main (Wladimir J. van der Laan)

Pull request description:

  Return `1` from `main()` on error, not the bool `false` (introduced in bitcoin#13112). This is the correct value to return on error, and also shuts up a clang warning.

Tree-SHA512: 52a0f1b2f6ae2697555f71ee2019ce657046f7f379f1f4faf3cce9d5f3fb21fcdc43a4c84895a2a8b6929997ba70bbe87c231f2f9553215b84c22333810d58d9
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants