Fix final sign comparison warnings (major source of main.h warning spew) #1142

pull jgarzik wants to merge 1 commits into bitcoin:master from jgarzik:sign-compare changing 2 files +10 −10
  1. jgarzik commented at 5:00 AM on April 24, 2012: contributor

    After this commit, "-Wall" only produces two warnings on my platform.

    This was sent under a separate cover because it deserves additional review. It changes (slightly) the usage of some serialized objects in a hopefully-superficial way.

  2. Canonicalize nFile usage, using zero for 'null' value, rather than -1
    It is defined as a 'unsigned int' and our first valid value is 1.
    b29a4a3d02
  3. in src/main.h:None in b29a4a3d02
     175 | @@ -176,8 +176,8 @@ class CInPoint
     176 |  
     177 |      CInPoint() { SetNull(); }
     178 |      CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; }
     179 | -    void SetNull() { ptx = NULL; n = -1; }
    


    sipa commented at 1:17 AM on April 26, 2012:

    You can't change the binary serialization of these, as they are part of the network protocol (coinbase transactions use an IsNull() COutPoint as input). Using 0xFFFFFFFF as initialization/test value works fine.


    Diapolo commented at 10:19 PM on April 29, 2012:

    At least n = -1 is undefined, as n is defined as unsigned.


    jgarzik commented at 10:42 PM on April 29, 2012:

    "unsigned int n = -1" is not undefined, but has a well understood behavior.


    Diapolo commented at 10:54 PM on April 29, 2012:

    Sorry for my nescience, the value is then 2^32 - 1, right?


    jgarzik commented at 11:10 PM on April 29, 2012:

    Yes, 0xFFFFFFFF as sipa noted.

  4. jgarzik commented at 6:44 PM on April 30, 2012: contributor

    Closing, due to @sipa comments

  5. jgarzik closed this on Apr 30, 2012

  6. suprnurd referenced this in commit 7a005a911e on Dec 5, 2017
  7. lateminer referenced this in commit df17427c86 on Jan 22, 2019
  8. lateminer referenced this in commit 17ad5a2a61 on Dec 25, 2019
  9. msgilligan referenced this in commit df0f941b74 on Jul 8, 2020
  10. DrahtBot locked this on Sep 8, 2021
Contributors

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 site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me