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
  1. laanwj commented at 6:45 pm on May 30, 2018: member
    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.
  2. laanwj added the label Tests on May 30, 2018
  3. jb55 approved
  4. jb55 commented at 6:58 pm on May 30, 2018: member
    ACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
  5. ken2812221 approved
  6. ken2812221 commented at 7:00 pm on May 30, 2018: contributor
    utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
  7. 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?
  8. MarcoFalke commented at 7:59 pm on May 30, 2018: member
    Concept ACK. Similar to qt’s main we could return EXIT_SUCCESS at the end or EXIT_FAILURE on an init error.
  9. 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?

  10. achow101 commented at 8:28 pm on May 30, 2018: member
    utACK cd2e257cb05a89870ac3a511b0e4c4c98b86e93e
  11. 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_FAILURE would 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.

  12. Empact commented at 11:58 pm on May 30, 2018: member
    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
  13. laanwj force-pushed on May 31, 2018
  14. bench: 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.
    493a166948
  15. laanwj force-pushed on May 31, 2018
  16. laanwj commented at 5:37 am on May 31, 2018: member
    Seemingly, I’ve been dragged along into updating the function for the latest fashion standards. Please re-review!
  17. fanquake commented at 6:34 am on May 31, 2018: member
    utACK 493a166
  18. promag commented at 7:47 am on May 31, 2018: member
    utACK 493a166.
  19. MarcoFalke merged this on May 31, 2018
  20. MarcoFalke closed this on May 31, 2018

  21. MarcoFalke referenced this in commit 24f7011841 on May 31, 2018
  22. UdjinM6 referenced this in commit 7cc2a393d5 on Jun 19, 2021
  23. UdjinM6 referenced this in commit 66a5131356 on Jun 24, 2021
  24. UdjinM6 referenced this in commit 7af7c7a220 on Jun 26, 2021
  25. UdjinM6 referenced this in commit d79c82aa95 on Jun 26, 2021
  26. UdjinM6 referenced this in commit a9dc0f3cda on Jun 28, 2021
  27. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

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: 2024-12-18 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me