tidy: modernize-use-nullptr #24971

pull fanquake wants to merge 2 commits into bitcoin:master from fanquake:clang_tidy_nullptr changing 12 files +29 −13
  1. fanquake commented at 11:54 AM on April 25, 2022: member

    Alternative to #15112 which uses clang-tidy to do perform the checking, rather than -Wzero-as-null-pointer-constant, and avoids having to uses pragmas, i.e:

    #if defined(HAVE_CONFIG_H)
    #include <config/bitcoin-config.h>
    #endif
    
    #if defined(HAVE_W_ZERO_AS_NULL_POINTER_CONSTANT)
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
    #pragma GCC diagnostic ignored "-Wunknown-pragmas"
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
    #endif
    

    to suppress warnings coming from upstream code.

    Can be tested by dropping the preceding commit. Should produce errors like:

    clang-tidy-14 --use-color -p=/home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp
    /home/ubuntu/ci_scratch/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/netbase.cpp:678:36: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
            if (!Socks5(strDest, port, 0, sock)) {
                                       ^
                                       nullptr
    
    
  2. in src/.bear-config:7 in 95ed7e5793 outdated
       0 | @@ -0,0 +1,15 @@
       1 | +{
       2 | +  "output": {
       3 | +    "content": {
       4 | +      "include_only_existing_source": true,
       5 | +      "paths_to_include": [],
       6 | +      "paths_to_exclude": [
       7 | +        "src/leveldb"
    


    MarcoFalke commented at 12:04 PM on April 25, 2022:

    Maybe this file should be called bear-tidy-config, as it is missing files that would otherwise be compiled in a normal (non-tidy) build?


    fanquake commented at 9:50 AM on April 26, 2022:

    Have renamed to .bear-tidy-config.

  3. MarcoFalke approved
  4. fanquake cross-referenced this on Apr 25, 2022 from issue build: Optionally enable -Wzero-as-null-pointer-constant by Empact
  5. DrahtBot added the label Build system on Apr 25, 2022
  6. DrahtBot added the label GUI on Apr 25, 2022
  7. DrahtBot added the label P2P on Apr 25, 2022
  8. DrahtBot added the label Wallet on Apr 25, 2022
  9. fanquake removed the label GUI on Apr 25, 2022
  10. fanquake removed the label Wallet on Apr 25, 2022
  11. fanquake removed the label Build system on Apr 25, 2022
  12. fanquake removed the label P2P on Apr 25, 2022
  13. DrahtBot added the label Build system on Apr 25, 2022
  14. DrahtBot added the label GUI on Apr 25, 2022
  15. DrahtBot added the label P2P on Apr 25, 2022
  16. DrahtBot added the label Wallet on Apr 25, 2022
  17. DrahtBot commented at 5:57 PM on April 25, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24185 (refactor: only use explicit reinterpret/const casts, not implicit by PastaPastaPasta)

    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.

  18. DrahtBot cross-referenced this on Apr 26, 2022 from issue refactor: only use explicit reinterpret/const casts, not implicit by PastaPastaPasta
  19. Don't use zero as null pointer constant (-Wzero-as-null-pointer-constant) e53274868e
  20. tidy: enable modernize-use-nullptr 9c96f1008b
  21. fanquake force-pushed on Apr 26, 2022
  22. MarcoFalke removed the label GUI on Apr 26, 2022
  23. MarcoFalke removed the label Wallet on Apr 26, 2022
  24. MarcoFalke removed the label Build system on Apr 26, 2022
  25. MarcoFalke removed the label P2P on Apr 26, 2022
  26. MarcoFalke added the label Refactoring on Apr 26, 2022
  27. MarcoFalke approved
  28. in src/.bear-tidy-config:15 in 9c96f1008b
      10 | +    "format": {
      11 | +      "command_as_array": true,
      12 | +      "drop_output_field": false
      13 | +    }
      14 | +  }
      15 | +}
    


  29. laanwj commented at 1:05 PM on April 26, 2022: member

    Concept and code review ACK 9c96f1008b4997aea31f293fed31f98ed3becfcf

    avoids having to uses pragmas

    Much better.

  30. fanquake merged this on Apr 26, 2022
  31. fanquake closed this on Apr 26, 2022

  32. fanquake deleted the branch on Apr 26, 2022
  33. sidhujag referenced this in commit 09047541df on Apr 26, 2022
  34. PastaPastaPasta referenced this in commit 8b56495b90 on Oct 18, 2022
  35. bitcoin locked this on Apr 26, 2023

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-05-19 06:53 UTC