The variable is conditionally assigned toward the end of the loop and not used after. It's then set back to its default value at the beginning of the loop.
Remove unused variable assignment #31497
pull yancyribbens wants to merge 1 commits into bitcoin:master from yancyribbens:remove-unused-var-assighnment changing 1 files +0 −1-
yancyribbens commented at 3:01 AM on December 14, 2024: contributor
-
b9766c9977
Remove unused variable assignment
The variable is conditionally assigned toward the end of the loop and not used after. It's then set back to its default value at the beginning of the loop.
-
DrahtBot commented at 3:02 AM on December 14, 2024: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage & Benchmarks
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31497.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers ACK theuni, hodlinator, danielabrozzoni, murchandamus, achow101 If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
-
theuni commented at 5:18 PM on December 16, 2024: member
Looks like the same is true for
should_shiftbelow. Paging @murchandamus just to make sure those vars are scoped as-intended and that this isn't pointing out a bug. -
yancyribbens commented at 5:23 PM on December 16, 2024: contributor
I don't think the same is true for
should_shift. It's last assigned on L505 but that's inside a while loop that depends on the condition ofshould_shift. -
theuni commented at 5:31 PM on December 16, 2024: member
Ah, of course you're right. I didn't notice that loop condition.
Sorry for the noise.
-
yancyribbens commented at 7:17 PM on December 17, 2024: contributor
Sorry for the noise.
No problem. It's pretty plain to see that this variable isn't used and can be removed. Not sure if it's worth bugging Murch to look at.
-
theuni commented at 1:49 PM on December 18, 2024: member
Sorry for the noise.
No problem. It's pretty plain to see that this variable isn't used and can be removed. Not sure if it's worth bugging Murch to look at.
Yes, agreed. I pinged because I thought there was more than 1 instance, which might have pointed out a broken refactor at some point. But yeah, it's pretty clearly just an unnecessary assignment.
utACK b9766c9977e58a9ebc358d9879576376e76a72b1
- hodlinator approved
-
hodlinator commented at 11:20 AM on December 19, 2024: contributor
crACK b9766c9977e58a9ebc358d9879576376e76a72b1
This dead store was a leftover from the introduction of CoinGrinder in 6cc9a46cd0f4ed80d4523bbef1508142e0c80d27 / #27877.
Checked that there are no shenanigans with the variable being captured into a lambda further up which is then called further down.
- maflcko requested review from murchandamus on Dec 19, 2024
- danielabrozzoni approved
-
danielabrozzoni commented at 5:53 PM on December 23, 2024: member
code review ACK b9766c9977e58a9ebc358d9879576376e76a72b1
- murchandamus approved
-
murchandamus commented at 6:57 PM on December 26, 2024: contributor
I surmise that I was resetting
should_cutin the block that performs the "cut" operation, because performing the cut removes the need for a cut. I agree that the assignment to false is unnecessary, as the variables are recreated at the start of the loop, and starting with fresh variables each loop is easier to parse than instantiating outside of the loop and ensuring whether the flags are cleaned up correctly after each operation.ACK b9766c9977e58a9ebc358d9879576376e76a72b1
-
achow101 commented at 6:06 PM on December 30, 2024: member
ACK b9766c9977e58a9ebc358d9879576376e76a72b1
- achow101 merged this on Dec 30, 2024
- achow101 closed this on Dec 30, 2024
-
yancyribbens commented at 9:34 PM on December 30, 2024: contributor
Thanks for the reviews.
- sedited referenced this in commit 230a439a4a on Jan 17, 2025
- stickies-v referenced this in commit d760fd3dda on Mar 17, 2025
- stickies-v referenced this in commit cc83553352 on Mar 17, 2025
- stickies-v referenced this in commit 2614933f06 on Mar 17, 2025
- stickies-v referenced this in commit b70418c5fc on Mar 17, 2025
- stickies-v referenced this in commit 69f8a1fe50 on Mar 17, 2025
- bug-castercv502 referenced this in commit 44b075fe71 on Sep 28, 2025
- bitcoin locked this on Dec 30, 2025