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.
bench: Don't return a bool from main #13349
pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2017_05_bench_warning changing 1 files +5 −4-
laanwj commented at 6:45 PM on May 30, 2018: member
- laanwj added the label Tests on May 30, 2018
- jb55 approved
-
jb55 commented at 6:58 PM on May 30, 2018: member
ACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
- ken2812221 approved
-
ken2812221 commented at 7:00 PM on May 30, 2018: contributor
utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
-
sipa commented at 7:10 PM on May 30, 2018: member
ACK. Also, why does that function not have a return statement at the end?
-
MarcoFalke commented at 7:59 PM on May 30, 2018: member
Concept ACK. Similar to qt's main we could return
EXIT_SUCCESSat the end orEXIT_FAILUREon an init error. -
promag commented at 8:07 PM on May 30, 2018: member
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 commented at 8:28 PM on May 30, 2018: member
utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
-
in src/bench/bench_bitcoin.cpp:49 in cd2e257cb0 outdated
45 | @@ -46,7 +46,7 @@ main(int argc, char** argv) 46 | std::string error; 47 | if (!gArgs.ParseParameters(argc, argv, error)) { 48 | fprintf(stderr, "Error parsing command line arguments: %s\n", error.c_str()); 49 | - return false; 50 | + return 1;
Empact commented at 10:10 PM on May 30, 2018:EXIT_FAILUREwould be more explicit.
laanwj commented at 5:14 AM on May 31, 2018: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 commented at 11:58 PM on May 30, 2018: memberWould 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 force-pushed on May 31, 2018493a166948bench: Don't return a bool from main
Return `EXIT_SUCCESS` 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. Also add a final return for clarity.
laanwj force-pushed on May 31, 2018laanwj commented at 5:37 AM on May 31, 2018: memberSeemingly, I've been dragged along into updating the function for the latest fashion standards. Please re-review!
fanquake commented at 6:34 AM on May 31, 2018: memberutACK 493a166
promag commented at 7:47 AM on May 31, 2018: memberutACK 493a166.
MarcoFalke merged this on May 31, 2018MarcoFalke closed this on May 31, 2018MarcoFalke referenced this in commit 24f7011841 on May 31, 2018UdjinM6 referenced this in commit 7cc2a393d5 on Jun 19, 2021UdjinM6 referenced this in commit 66a5131356 on Jun 24, 2021UdjinM6 referenced this in commit 7af7c7a220 on Jun 26, 2021UdjinM6 referenced this in commit d79c82aa95 on Jun 26, 2021UdjinM6 referenced this in commit a9dc0f3cda on Jun 28, 2021MarcoFalke locked this on Sep 8, 2021Labels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-05 06:15 UTC
More mirrored repositories can be found on mirror.b10c.me