Fixes #27679 (review)
refactor: Avoid unused-variable warning in init.cpp #29968
pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2404-init- changing 1 files +2 −4-
maflcko commented at 8:18 AM on April 26, 2024: member
-
DrahtBot commented at 8:18 AM on April 26, 2024: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
Code Coverage
For detailed information about the code coverage, see the test coverage report.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
Type Reviewers ACK TheCharlatan Stale ACK pinheadmz, hebasto If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #29432 (Stratum v2 Template Provider (take 3) by Sjors)
- #25972 (build: no-longer disable WARN_CXXFLAGS when CXXFLAGS is set by fanquake)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
- DrahtBot added the label Refactoring on Apr 26, 2024
-
fanquake commented at 8:54 AM on April 26, 2024: member
Pulled it in
- hebasto approved
-
hebasto commented at 9:53 AM on April 26, 2024: member
ACK fa5ba429a71eb81848560b4a547d1717efd33593, tested on Ubuntu 24.04 with
-Wall. -
in src/init.cpp:1304 in fa5ba429a7 outdated
1300 | @@ -1301,7 +1301,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) 1301 | } 1302 | } 1303 | 1304 | - for (const auto &port_option : std::vector<std::pair<std::string, bool>>{ 1305 | + for (const auto& [arg, unix] : std::vector<std::pair<std::string, bool>>{
laanwj commented at 12:00 PM on April 26, 2024:ACK on improving the syntax, but it seems a matter of time before the compiler again becomes smart enough to see this variable is unused? Mayb eadd
(void)unix;to the
!HAVE_SOCKADDR_UNpath just in case?maflcko force-pushed on Apr 26, 2024in src/init.cpp:1320 in fa141d27cc outdated
1314 | @@ -1315,20 +1315,18 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) 1315 | {"-zmqpubrawtx", true}, 1316 | {"-zmqpubsequence", true} 1317 | }) { 1318 | - const std::string arg{port_option.first}; 1319 | - const bool unix{port_option.second}; 1320 | +#if HAVE_SOCKADDR_UN 1321 | +#else 1322 | + unix = false;
laanwj commented at 12:42 PM on April 26, 2024:Now you're assigning a value that isn't used, i think that will generate a warning too. Doesn't the suggested
(void)unix;work to simulate a read?Or maybe, even check it and raise an error. Eg.
if (unix) { Error("This platform does not support UNIX sockets."); }
maflcko commented at 1:48 PM on April 26, 2024:Or maybe, even check it and raise an error. Eg.
Sure, happy to close this pull if someone creates an alternative, but I'll probably leave this pull as-is
maflcko force-pushed on Apr 26, 2024DrahtBot added the label CI failed on Apr 26, 2024DrahtBot commented at 12:49 PM on April 26, 2024: contributor<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed. Make sure to run all tests locally, according to the documentation.
Possibly this is due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
Leave a comment here, if you need help tracking down a confusing failure.
<sub>Debug: https://github.com/bitcoin/bitcoin/runs/24297453221</sub>
DrahtBot removed the label CI failed on Apr 26, 2024pinheadmz approvedpinheadmz commented at 5:10 PM on April 30, 2024: memberACK fa2353d9c3ff68995e7478b9b80dcdb1fc638a53
Confirmed the warning on master by setting
-Walland then forcingHAVE_SOCKADDR_UN = 0inconfigure.ac. This patch fixes the warning in a clean way. I dunno if(void)unix;needs an explanatory comment or if thats a recognizable pattern for this kind of thing.Thanks again @maflcko for cleaning up my mess 😬
<details><summary>Show Signature</summary>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 ACK fa2353d9c3ff68995e7478b9b80dcdb1fc638a53 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE5hdzzW4BBA4vG9eM5+KYS2KJyToFAmYxJW0ACgkQ5+KYS2KJ yTpXqg//VS2W2FATmVSHha7wDo/Kaj3rFAIH9nxlKr9tEeZCda2DCsY0bD8IYi53 1mfvrPhEpwhyv85Rztx35PEnGz7mvwWcL62diicx+qYTmy6DtctwzvRN9SKatF/V xIVm8aPVHrcczlw30vvturmiZDvP0iFg8n6LpjZZvHmqiPYAQQ/wP63iaaYSdARY iYb1cV5sZgh80Q6Tiy08/qTUyWxgwE50LXbAeyu7ZPx9yY6jOWxL3LP1o+0ZTkbH 1SWYjrdC2S+NxbMf5PfiT3VezA5Lezk90wZzgUjuPexzZChk1mZTh+XKn4RLTSGy xqLAu9TPMylmuEsMb70g0YLsZHFdQI2k84xwZwmyXhLN77zWncFNmJiXQbmJoSWv +BSGg/2tROOHs/KtbY50HVnVv1Fv5FPlg5llRH0EpaeFGlYn7pHt2x61uDjf83Wy +dQU2Cx+L2AgioC0CD6tQzuSaklweFQw+t8wRVnC8gyS2ftBT99TB7/qCB0h0/vq lypmobdOofSfEea/i13L91vGxyv7F9rw7SimzbPMPUaYzZs6OA3c9rLbcabPbja/ YdygzdYZKmTUKeExMNjCGyxRp+swIDTPwT3Ca9N00+vN+eVzfIbSDoXaVj7ZWzIO aSPqUMdCjLiqAJ/AcFSBKFLUTCcg+99rcfA4/kkduQxJaGdNF04= =Pu5n -----END PGP SIGNATURE-----pinheadmz's public key is on keybase
</details>
DrahtBot requested review from hebasto on Apr 30, 2024hebasto approvedhebasto commented at 5:37 PM on April 30, 2024: memberre-ACK fa2353d9c3ff68995e7478b9b80dcdb1fc638a53.
fanquake commented at 8:06 AM on May 1, 2024: memberCould be:
diff --git a/src/init.cpp b/src/init.cpp index 4d7638cd6e..ebfcb9cf8e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1312,7 +1312,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) {"-zmqpubsequence", true} }) { const std::string arg{port_option.first}; - const bool unix{port_option.second}; + [[maybe_unused]] const bool unix{port_option.second}; for (const std::string& socket_addr : args.GetArgs(arg)) { std::string host_out; uint16_t port_out{0};Avoids the worry about future compilers, and (void)blah which isn't explanatory
refactor: Avoid unused-variable warning in init.cpp fa9abf9688maflcko force-pushed on May 2, 2024maflcko commented at 10:51 AM on May 2, 2024: memberAvoids the worry about future compilers, and (void)blah which isn't explanatory
I think
(void)blah;is well understood to mean this (to both code readers and compilers), but[[maybe_unused]]seems fine as well. Switched to that.TheCharlatan approvedTheCharlatan commented at 1:00 PM on May 2, 2024: contributorACK fa9abf968840745e428a86a9545aaa6c923415e2
DrahtBot requested review from hebasto on May 2, 2024DrahtBot requested review from pinheadmz on May 2, 2024fanquake merged this on May 2, 2024fanquake closed this on May 2, 2024maflcko deleted the branch on May 2, 2024kwvg referenced this in commit cef9064e8b on Apr 19, 2025kwvg referenced this in commit 96846d39f2 on Apr 19, 2025kwvg referenced this in commit d942f13992 on Apr 22, 2025kwvg referenced this in commit 10c7c1d204 on Apr 22, 2025PastaPastaPasta referenced this in commit 713f90e31a on Apr 25, 2025bitcoin locked this on May 2, 2025
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-13 15:13 UTC
More mirrored repositories can be found on mirror.b10c.me