Libraries: Use correct type ; avoid compiler warnings. #12351

pull murrayn wants to merge 1 commits into bitcoin:master from murrayn:ptrdiff_t changing 1 files +3 −3
  1. murrayn commented at 10:58 AM on February 5, 2018: contributor

    ptrdiff_t is a more strictly correct type, and gets rid of compiler warnings.

  2. Use ptrdiff_t type to more precisely indicate usage and avoid compiler warnings. a25cb0f313
  3. fanquake added the label Refactoring on Feb 5, 2018
  4. MarcoFalke commented at 12:28 PM on February 5, 2018: member

    Duplicate of #12286

  5. MarcoFalke marked this as duplicate on Feb 5, 2018
  6. murrayn commented at 12:01 AM on February 6, 2018: contributor

    I wasn't aware of another PR dealing with the compiler warnings. However, the solutions are not duplicates. I think changing the type to ptrdiff_t as I do here is more correct than the casting solution. The cast solution is just masking the problem.

  7. murrayn renamed this:
    Libraries: Use type more precisely indicating usage and avoid compilers warnings.
    Libraries: Use correct type ; avoid compiler warnings.
    on Feb 7, 2018
  8. laanwj commented at 7:46 PM on February 8, 2018: member

    One question though, for @sipsorcery maybe - is ptrdiff_t supported with MSVC? We're not using it anywhere and I remember problems with ssize_t.

  9. practicalswift commented at 9:08 PM on February 8, 2018: contributor

    utACK a25cb0f313315bd987834aa5f500b5682a9c3cd5

  10. Empact commented at 9:22 PM on February 8, 2018: member
  11. Empact commented at 9:48 PM on February 8, 2018: member

    utACK a25cb0f

    I prefer this over #12286

  12. sipsorcery commented at 9:51 PM on February 8, 2018: member

    @laanwj ptrdiff_t is defined in vcruntime.h with MSVC. This change builds with Visual Studio.

  13. laanwj commented at 10:37 AM on February 12, 2018: member

    @sipsorcery Thanks for checking!

  14. in src/key.cpp:69 in a25cb0f313
      65 | @@ -66,7 +66,7 @@ static int ec_privkey_import_der(const secp256k1_context* ctx, unsigned char *ou
      66 |      if (end - privkey < 2 || privkey[0] != 0x04u) {
      67 |          return 0;
      68 |      }
      69 | -    size_t oslen = privkey[1];
      70 | +    ptrdiff_t oslen = privkey[1];
    


    laanwj commented at 10:40 AM on February 12, 2018:

    Checked that neither of the values whose type changed can ever be negative, or overflow, given that the range of privkey[x] is 0..255.

  15. laanwj merged this on Feb 12, 2018
  16. laanwj closed this on Feb 12, 2018

  17. laanwj referenced this in commit c8b54b2044 on Feb 12, 2018
  18. PastaPastaPasta referenced this in commit 3d5ac7e5db on Jun 10, 2020
  19. PastaPastaPasta referenced this in commit ebcdf8c28c on Jun 12, 2020
  20. PastaPastaPasta referenced this in commit 69e76bd9cd on Jun 13, 2020
  21. PastaPastaPasta referenced this in commit 1be7b4d1d9 on Jun 14, 2020
  22. PastaPastaPasta referenced this in commit 7dc8c4e687 on Jun 14, 2020
  23. gades referenced this in commit b22cb62c00 on Jun 24, 2021
  24. DrahtBot locked this on Sep 8, 2021

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-21 18:15 UTC

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