clang-tidy: Fix modernize-use-nullptr in headers #26708

pull hebasto wants to merge 1 commits into bitcoin:master from hebasto:221215-tidy-null changing 1 files +5 −4
  1. hebasto commented at 9:08 pm on December 15, 2022: member

    Split from bitcoin/bitcoin#26705 as was requested in #26705 (comment).

    To test this PR, consider applying a diff as follows:

     0--- a/src/.clang-tidy
     1+++ b/src/.clang-tidy
     2@@ -12,17 +12,9 @@ readability-redundant-declaration,
     3 readability-redundant-string-init,
     4 '
     5 WarningsAsErrors: '
     6-bugprone-argument-comment,
     7-bugprone-use-after-move,
     8-misc-unused-using-decls,
     9-modernize-use-default-member-init,
    10 modernize-use-nullptr,
    11-performance-for-range-copy,
    12-performance-move-const-arg,
    13-performance-unnecessary-copy-initialization,
    14-readability-redundant-declaration,
    15-readability-redundant-string-init,
    16 '
    17 CheckOptions:
    18  - key: performance-move-const-arg.CheckTriviallyCopyableMove
    19    value: false
    20+HeaderFilterRegex: '.'
    
  2. clang-tidy: Fix `modernize-use-nullptr` in headers
    https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-nullptr.html
    adb7dba9de
  3. DrahtBot commented at 9:08 pm on December 15, 2022: contributor

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK john-moffett
    Concept ACK kevkevinpal

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #26705 (clang-tidy: Check headers and fixes them by hebasto)

    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.

  4. kevkevinpal approved
  5. kevkevinpal commented at 7:16 am on December 16, 2022: contributor
    ACK but I’m going to try and run clang-tidy myself, first time doing so it might take me a bit
  6. kevkevinpal commented at 7:33 am on December 16, 2022: contributor
    was able to run clang-tidy but I only saw a message for this part of the code FormatListN() : FormatList(nullptr, 0) {} not sure how to get clang-tidy to complain about the 3 NULL values changed to nullptr
  7. hebasto commented at 10:32 am on December 16, 2022: member

    @kevkevinpal

    not sure how to get clang-tidy to complain about the 3 NULL values changed to nullptr

    To observe clang-tidy’s errors, one could apply to the master branch a diff as follows:

     0--- a/src/.clang-tidy
     1+++ b/src/.clang-tidy
     2@@ -12,17 +12,9 @@ readability-redundant-declaration,
     3 readability-redundant-string-init,
     4 '
     5 WarningsAsErrors: '
     6-bugprone-argument-comment,
     7-bugprone-use-after-move,
     8-misc-unused-using-decls,
     9-modernize-use-default-member-init,
    10 modernize-use-nullptr,
    11-performance-for-range-copy,
    12-performance-move-const-arg,
    13-performance-unnecessary-copy-initialization,
    14-readability-redundant-declaration,
    15-readability-redundant-string-init,
    16 '
    17 CheckOptions:
    18  - key: performance-move-const-arg.CheckTriviallyCopyableMove
    19    value: false
    20+HeaderFilterRegex: '.'
    

    and, for example, run a CI task locally:

    0$ MAKEJOBS="-j16" FILE_ENV="./ci/test/00_setup_env_native_tidy.sh" ./ci/test_run_all.sh
    

    or in a personal Cirrus account: https://cirrus-ci.com/task/4659814702252032.

    My local run has in output:

     0/home/hebasto/git/bitcoin/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/./tinyformat.h:511:23: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
     1            : m_value(NULL),
     2                      ^~~~
     3                      nullptr
     4/home/hebasto/git/bitcoin/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/./tinyformat.h:512:26: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
     5            m_formatImpl(NULL),
     6                         ^~~~
     7                         nullptr
     8/home/hebasto/git/bitcoin/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/./tinyformat.h:513:25: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
     9            m_toIntImpl(NULL)
    10                        ^~~~
    11                        nullptr
    12/home/hebasto/git/bitcoin/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/src/./tinyformat.h:1008:40: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
    13    public: FormatListN() : FormatList(0, 0) {}
    14                                       ^
    15                                       nullptr
    
  8. john-moffett approved
  9. john-moffett commented at 6:45 pm on December 16, 2022: contributor
    ACK adb7dba9de95c166103ac7eaf97d5bd83dc19605
  10. maflcko merged this on Dec 17, 2022
  11. maflcko closed this on Dec 17, 2022

  12. hebasto deleted the branch on Dec 17, 2022
  13. sidhujag referenced this in commit fd665e9f18 on Dec 17, 2022
  14. kevkevinpal commented at 10:07 pm on December 17, 2022: contributor
    @hebasto thanks I think I was able to figure it out, I ran the CI task locally and then did docker exec -it <containerid> /bin/bash then ran clang-tidy ./src/tinyformat.h and was able to get the correct warning message
  15. bitcoin locked this on Dec 17, 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: 2024-07-01 13:12 UTC

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