ConnectBlock(): fix error() format to be unsigned #2022

pull Diapolo wants to merge 1 commits into bitcoin:master from Diapolo:fix_#2018 changing 1 files +1 −1
  1. Diapolo commented at 8:48 PM on November 16, 2012: none
    • I introduced the wrong format macro with my former patch (#2018), this needs to be signed not unsigned (thanks Luke-Jr)
  2. Diapolo commented at 9:03 PM on November 16, 2012: none

    These were the warning my patch fixes: src\main.cpp: In member function 'bool CBlock::ConnectBlock(CBlockIndex*, CCoinsViewCache&, bool)': src\main.cpp:warning: unknown conversion type character 'l' in format [-Wformat] src\main.cpp:warning: unknown conversion type character 'l' in format [-Wformat] src\main.cpp:warning: too many arguments for format [-Wformat-extra-args]

  3. luke-jr commented at 9:36 PM on November 16, 2012: member

    Looks like a bug in Microsoft printf family of functions :(

    ACK for 0.7.2 & master

  4. Diapolo commented at 9:40 PM on November 16, 2012: none

    Thanks for taking a look and I wanted to clarify why I patched it :).

  5. sipa commented at 10:27 PM on November 16, 2012: member

    ACK

  6. jgarzik commented at 12:51 AM on November 17, 2012: contributor

    Please fix the commit message. The one-line summary of your change, as it appears in "git shortlog" and other tools, is wholly useless: "fix pull #2018"

    That is utterly meaningless without further research; it tells nothing about what code is modified, or how it was modified, or why it needed modification.

    We use "git shortlog" to generate summaries for release notes and other purposes. The first line is a summary of the change, and for this, probably should be something like "ConnectBlock: fix error() format to be unsigned" etc.

  7. laanwj commented at 1:33 AM on November 17, 2012: member

    How is this a bug in the Microsoft printf function @Luke-Jr?

  8. luke-jr commented at 1:45 AM on November 17, 2012: member

    @laanwj %lld is standard C printf format, but not supported by Microsoft's printf: http://sourceforge.net/tracker/?func=detail&atid=102435&aid=1963136&group_id=2435

  9. laanwj commented at 1:47 AM on November 17, 2012: member

    Ooh, okay something made by MS is incompatible to the standards, now that's a now one, let's call the press :)

  10. laanwj commented at 8:22 AM on November 17, 2012: member

    I still don't get those warnings though. We define:

    #ifndef PRI64d
    #if defined(_MSC_VER) || defined(__MSVCRT__)
    #define PRI64d  "I64d"
    #define PRI64u  "I64u"
    #define PRI64x  "I64x"
    #else
    #define PRI64d  "lld"
    #define PRI64u  "llu"
    #define PRI64x  "llx"
    #endif
    #endif
    

    Which means that in the case of MS, we use "special" retarded character sequences. The thing is, there is no 'l' in any of those. So where does that warning come from?

  11. luke-jr commented at 8:35 AM on November 17, 2012: member

    @laanwj The original code which Diapolo is referring to used %lld; he replaced that with PRI64u, but it needs to be PRI64d since the argument is signed.

  12. laanwj commented at 8:45 AM on November 17, 2012: member

    Right, I get it now, thanks

  13. ConnectBlock(): fix error() format to be unsigned
    - I introduced the wrong format macro with my former patch (#2018), this
      needs to be signed not unsigned (thanks Luke-Jr)
    11406c89fe
  14. Diapolo commented at 8:59 AM on November 17, 2012: none

    @jgarzik Sorry, yes it was a weak commit message :), fixed it!

  15. laanwj referenced this in commit 4725e96a3a on Nov 17, 2012
  16. laanwj merged this on Nov 17, 2012
  17. laanwj closed this on Nov 17, 2012

  18. laudney referenced this in commit 4c5a8e64bc on Mar 19, 2014
  19. KolbyML referenced this in commit 8385a96f94 on Dec 5, 2020
  20. 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-15 15:15 UTC

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