Goto3 #97

pull iangfc wants to merge 2 commits into bitcoin-core:master from iangfc:goto3 changing 2 files +7 −12
  1. iangfc commented at 7:22 pm on November 8, 2014: contributor

    Removed 3 gotos. Their style makes it hard for readers to trace, and maintainers can make mistakes too easily.

    (Also included is fix to configure to allow homebrew, another MacOSX package manager, to provide the needed libraries. Homebrew uses /usr/local rather than /opt/local which is the domain of macports.)

  2. Compile using homebrew's /usr/local/ (as well as macports /opt/). 1f901f4d2a
  3. Removed gotos, which are hard to trace and maintain. a7347e0ea4
  4. gmaxwell commented at 7:33 pm on November 8, 2014: contributor

    From a control flow complexity perspective multiple returns and goto are equivilent; and I’ve seen them lead to the same bugs.

    This can be done here since it just recently dropped support for number types that need deallocation, though it does now have a risk of gaining a memory leak if they’re reintroduced (“oh well”). (And probably should; the error goto style is ideomatic C where deallocation needs to happen conditional on error, and not generally elsewhere).

    I have a mild preference for restructuing so that the return at the bottom is a failure, swapping the not on the last branch and making it return 1; just because the preference is for futuer bugs to return failure; but thats probably nitpicking pieter can comment.

  5. jgarzik commented at 7:57 pm on November 8, 2014: none

    -1

    It makes control flow easier to follow. “early return” can just as easily lead to bugs, so that is invalid logic as presented. goto error handling in C is extremely common and works just fine.

  6. sipa commented at 8:38 pm on November 8, 2014: contributor
    I agree that there is nothing actually wrong with using goto in this case (hey, I wrote it that way…), but it is effectively the only place in the codebase where goto’s are still used, so for consistency I’d rather get rid of them.
  7. iangfc commented at 9:34 pm on November 8, 2014: contributor
    Ha, didn’t mean to start a style war. Is there a style guide that is relevant?
  8. theuni commented at 5:39 pm on November 24, 2014: contributor
  9. sipa cross-referenced this on Feb 13, 2015 from issue Removed gotos, which are hard to trace and maintain. by sipa
  10. sipa commented at 0:52 am on February 13, 2015: contributor
    Closing in favor of #213
  11. sipa closed this on Feb 13, 2015


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 16:15 UTC

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