refactor: Silence "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp #15938

pull practicalswift wants to merge 1 commits into bitcoin:master from practicalswift:psbt-return-type-warning changing 1 files +2 −0
  1. practicalswift commented at 6:26 AM on May 2, 2019: contributor

    Silence GCC 7 warning "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp.

    Context: https://github.com/bitcoin/bitcoin/commit/ef22fe8c1f331b4f13f21a54d12030b92e83fbe7#r33370109

    Before this patch:

    $ ./configure CC=gcc-7 CXX=g++-7
    $ make 2>&1 | grep -A2 "warning: "
    leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               (v == kMaxUint64/10 && delta > kMaxUint64%10)) {
                                      ~~~~~~^~~~~~~~~~~~~~~
    --
    leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       return (ecx & (1 << 20)) != 0;
              ~~~~~^~~~~~~~~~~~
    --
    psbt.cpp:341:1: warning: control reaches end of non-void function [-Wreturn-type]
     }
     ^
    $
    

    After this patch:

    $ ./configure CC=gcc-7 CXX=g++-7
    $ make 2>&1 | grep -A2 "warning: "
    leveldb/util/logging.cc:58:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
               (v == kMaxUint64/10 && delta > kMaxUint64%10)) {
                                      ~~~~~~^~~~~~~~~~~~~~~
    --
    leveldb/port/port_posix.cc:60:15: warning: ‘ecx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       return (ecx & (1 << 20)) != 0;
              ~~~~~^~~~~~~~~~~~
    $
    
  2. practicalswift referenced this in commit ef22fe8c1f on May 2, 2019
  3. fanquake added the label Refactoring on May 2, 2019
  4. Empact commented at 8:17 AM on May 2, 2019: member

    Better to return outside the switch, I think, so the full coverage of the switch is still checked via -Wswitch. In that case could assert at the end instead, to show that it's never hit.

  5. practicalswift commented at 9:07 AM on May 2, 2019: contributor

    @Empact That's a good point! Adjusted accordingly (but without assert). Please re-review :-)

  6. practicalswift force-pushed on May 2, 2019
  7. laanwj commented at 11:25 AM on May 2, 2019: member

    Better to return outside the switch, I think, so the full coverage of the switch is still checked via -Wswitch. In that case could assert at the end instead, to show that it's never hit.

    The switch statement covers all possible options, I think it's strange to return a value that can never be returned, if an "unknown" value ends up it can only be due to memory corruption either a software or hardware bug. This would be the place for an assertion.

  8. practicalswift force-pushed on May 2, 2019
  9. Empact commented at 11:43 AM on May 2, 2019: member

    Generally I agree, but the only callers for this are to output directly to the user in analyzepsbt, so the options are: display "unknown" amongst other data, or fail out.

  10. practicalswift commented at 11:44 AM on May 2, 2019: contributor

    @laanwj Thanks for reviewing. Now asserting. Please re-review :-)

  11. MarcoFalke commented at 12:15 PM on May 2, 2019: member

    Could add the same documentation like elsewhere?

    git grep 'no default case'
    
  12. Silence GCC 7 warning "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp beb42d71a0
  13. practicalswift force-pushed on May 2, 2019
  14. practicalswift commented at 1:08 PM on May 2, 2019: contributor

    @MarcoFalke Good point! Added. Please re-review :-)

  15. MarcoFalke renamed this:
    Silence GCC 7 warning "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp
    refactor: Silence "control reaches end of non-void function" (-Wreturn-type) in psbt.cpp
    on May 2, 2019
  16. MarcoFalke referenced this in commit c1ba1182eb on May 2, 2019
  17. MarcoFalke merged this on May 2, 2019
  18. MarcoFalke closed this on May 2, 2019

  19. fanquake referenced this in commit dcc640811c on Oct 14, 2019
  20. practicalswift deleted the branch on Apr 10, 2021
  21. vijaydasmp referenced this in commit 0f6262c703 on Mar 16, 2022
  22. vijaydasmp referenced this in commit 4ba4a3909d on Mar 27, 2022
  23. vijaydasmp referenced this in commit d24df1083c on Mar 31, 2022
  24. vijaydasmp referenced this in commit bed15af23a on Mar 31, 2022
  25. vijaydasmp referenced this in commit db96b83da5 on Apr 1, 2022
  26. vijaydasmp referenced this in commit db662cf843 on Apr 2, 2022
  27. kittywhiskers referenced this in commit 5bc67cd78e on Apr 5, 2022
  28. kittywhiskers referenced this in commit 91651eef58 on Apr 5, 2022
  29. vijaydasmp referenced this in commit eff16241de on Apr 21, 2022
  30. gades referenced this in commit e138e1aa63 on Apr 21, 2022
  31. vijaydasmp referenced this in commit a15be53022 on May 10, 2022
  32. vijaydasmp referenced this in commit 0d983aeb50 on May 19, 2022
  33. vijaydasmp referenced this in commit 95a1ccde70 on May 19, 2022
  34. vijaydasmp referenced this in commit 79c7d4babd on May 19, 2022
  35. vijaydasmp referenced this in commit 07e0a34c07 on May 26, 2022
  36. vijaydasmp referenced this in commit 65d94d7b40 on Jun 14, 2022
  37. vijaydasmp referenced this in commit 89a3bf7417 on Jun 14, 2022
  38. vijaydasmp referenced this in commit 8a4b58d8a6 on Jun 15, 2022
  39. vijaydasmp referenced this in commit e066f32de5 on Jun 20, 2022
  40. vijaydasmp referenced this in commit 6cfcfc4ba8 on Jun 22, 2022
  41. vijaydasmp referenced this in commit 7703361c30 on Jun 22, 2022
  42. vijaydasmp referenced this in commit e3606d6751 on Jun 22, 2022
  43. vijaydasmp referenced this in commit aa4c60d648 on Jun 22, 2022
  44. vijaydasmp referenced this in commit 1ed73e6cda on Jun 26, 2022
  45. vijaydasmp referenced this in commit 1b390c1aa5 on Aug 11, 2022
  46. vijaydasmp referenced this in commit 6d4103fe8d on Aug 14, 2022
  47. DrahtBot locked this on Aug 16, 2022

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: 2026-04-16 15:14 UTC

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