refactor: Enable -Wswitch for FeeEstimateHorizon #20771

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2012-WswitchFeeEstimateHorizon changing 1 files +14 −21
  1. MarcoFalke commented at 11:43 AM on December 26, 2020: member

    This enables the -Wswitch compiler warning for FeeEstimateHorizon by removing the default case in switch statements.

  2. fanquake added the label Refactoring on Dec 26, 2020
  3. MarcoFalke force-pushed on Dec 26, 2020
  4. MarcoFalke force-pushed on Dec 26, 2020
  5. jonatack commented at 12:33 PM on December 26, 2020: member

    Concept ACK. I was making a similar refactoring here when adding the estimatefeerate rpc.

  6. mjdietzx commented at 3:07 PM on December 26, 2020: contributor

    concept ack fa88a3aeb42192133336233774ee12a1a22dd151

  7. refactor: Enable -Wswitch for FeeEstimateHorizon faccf8b1e1
  8. MarcoFalke force-pushed on Dec 26, 2020
  9. in src/policy/fees.cpp:661 in faccf8b1e1
     656 | @@ -660,10 +657,8 @@ CFeeRate CBlockPolicyEstimator::estimateRawFee(int confTarget, double successThr
     657 |          stats = longStats.get();
     658 |          break;
     659 |      }
     660 | -    default: {
     661 | -        throw std::out_of_range("CBlockPolicyEstimator::estimateRawFee unknown FeeEstimateHorizon");
     662 | -    }
     663 | -    }
     664 | +    } // no default case, so the compiler can warn about missing cases
     665 | +    assert(stats);
    


    jonatack commented at 9:30 PM on December 26, 2020:

    nit, assert(stats) seems to be checking for more than missing cases (like assert(false)), maybe update the comment


    hebasto commented at 9:45 PM on December 26, 2020:

    I think the comment and assert(stats); are independent here, as std::unique_ptr::get could return nullptr.


    jonatack commented at 11:22 PM on December 27, 2020:

    You're right, nvm

  10. jonatack commented at 9:30 PM on December 26, 2020: member

    ACK faccf8b1e1af293dfe9158d732718e7798a2fd89

  11. hebasto approved
  12. hebasto commented at 9:43 PM on December 26, 2020: member

    ACK faccf8b1e1af293dfe9158d732718e7798a2fd89, I have reviewed the code and it looks OK, I agree it can be merged.

  13. hebasto commented at 9:47 PM on December 26, 2020: member

    I was making a similar refactoring here when adding the estimatefeerate rpc.

    Me too: https://github.com/bitcoin-core/gui/pull/166 :)

  14. practicalswift commented at 10:55 PM on December 27, 2020: contributor

    cr ACK faccf8b1e1af293dfe9158d732718e7798a2fd89

  15. fanquake merged this on Dec 28, 2020
  16. fanquake closed this on Dec 28, 2020

  17. MarcoFalke deleted the branch on Dec 28, 2020
  18. sidhujag referenced this in commit 878d0220c8 on Dec 28, 2020
  19. DrahtBot locked this on Feb 15, 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-17 06:14 UTC

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