This really quiets down -Wall. We are down to 3 key signed/unsigned warnings in main.h, and 2-3 other misc. warnings overall.
Address many more sign comparison warnings #1140
pull jgarzik wants to merge 6 commits into bitcoin:master from jgarzik:sign-compare changing 13 files +74 −64-
jgarzik commented at 6:05 PM on April 22, 2012: contributor
-
faf705a42a
Prefer 'unsigned int' for loop index variables tested against ::size()
C++ STL ::size() generally returns unsigned, which implies that "int idx" style of loop variable will generate a signed-vs-unsigned comparison warning when testing the loop exit condition "idx < blah.size()" Update areas of the bitcoin code where loop variables may be more properly and correctly defined as unsigned.
-
7bd9c3a3cf
SigOp and orphan-tx constants and counts are always unsigned.
Fixes several sign-comparison warnings.
-
Test ScriptSigArgsExpected() for error, before accumulating return value c0a0a93d02
-
1d8c7a9557
Add casts for unavoidable signed/unsigned comparisons
At these code sites, it is preferable to cast rather than change a variable's type.
-
5aa0b23825
CBlock::WriteToDisk() properly checks ftell(3) for error return
Rather than storing ftell(3)'s return value -- a long -- in an unsigned int, we store and check a properly typed temp. Then, assured a non-negative value, we store in nBlockPosRet.
-
735a60698c
Change signed->unsigned at 3 code sites
This resolves signed/unsigned comparison warnings.
-
in src/main.cpp:None in 3b1a096229 outdated
194 | @@ -195,9 +195,9 @@ void static EraseOrphanTx(uint256 hash) 195 | mapOrphanTransactions.erase(hash); 196 | } 197 | 198 | -int LimitOrphanTxSize(int nMaxOrphans) 199 | +static unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
gavinandresen commented at 9:12 PM on April 22, 2012:Making this static breaks test/DoS_tests.cpp
jgarzik commented at 6:20 PM on April 23, 2012: contributorRE @gavinandresen:
Updated and rebased, to fix LimitOrphanTxSize() issue.
RE "Test ScriptSigArgsExpected() for error" -- I agree ScriptSigArgsExpected() may not return <0 given current conditions, but there are two advantages to the new code, a) the code is less fragile, in case those conditions change in the future. checking for an error that a function is pretty harmless, and trivial in terms of CPU cycles. b) the compiler's optimizer is guaranteed a non-negative value, enabling certain value-range optimizations.
gavinandresen commented at 6:27 PM on April 23, 2012: contributorACK.
jgarzik referenced this in commit c2e8c8acd8 on Apr 24, 2012jgarzik merged this on Apr 24, 2012jgarzik closed this on Apr 24, 2012coblee referenced this in commit ec93ad8369 on Jul 17, 2012suprnurd referenced this in commit 714f9a4f0d on Dec 5, 2017lateminer referenced this in commit 70fbbf7ae8 on Jan 22, 2019xdustinface referenced this in commit 33c0e6641b on Oct 2, 2020Bushstar referenced this in commit ba3c6519cd on Oct 21, 2020DrahtBot locked this on Sep 8, 2021Contributors
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-20 00:16 UTC
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-20 00:16 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me