tidy: Enable more clang-tidy bugprone checks #25780

pull aureleoules wants to merge 14 commits into bitcoin:master from aureleoules:2022-08-enable-bugprone-checks changing 20 files +52 −33
  1. aureleoules commented at 2:22 PM on August 4, 2022: member

    This PR enables more clang-tidy bugprone checks and fixes issues discovered by enabling them. Here are the checks now enabled: bugprone-argument-comment bugprone-assert-side-effect bugprone-assignment-in-if-condition bugprone-bad-signal-to-kill-thread bugprone-bool-pointer-implicit-conversion bugprone-copy-constructor-init bugprone-dangling-handle bugprone-dynamic-static-initializers bugprone-fold-init-type bugprone-forward-declaration-namespace bugprone-forwarding-reference-overload bugprone-inaccurate-erase bugprone-incorrect-roundings bugprone-infinite-loop bugprone-macro-repeated-side-effects bugprone-misplaced-operator-in-strlen-in-alloc bugprone-misplaced-pointer-arithmetic-in-alloc bugprone-move-forwarding-reference bugprone-multiple-statement-macro bugprone-no-escape bugprone-not-null-terminated-result bugprone-parent-virtual-call bugprone-posix-return bugprone-redundant-branch-condition bugprone-shared-ptr-array-mismatch bugprone-signal-handler bugprone-sizeof-container bugprone-sizeof-expression bugprone-spuriously-wake-up-functions bugprone-string-constructor bugprone-string-integer-assignment bugprone-string-literal-with-embedded-nul bugprone-stringview-nullptr bugprone-suspicious-enum-usage bugprone-suspicious-include bugprone-suspicious-memory-comparison bugprone-suspicious-memset-usage bugprone-suspicious-missing-comma bugprone-suspicious-semicolon bugprone-suspicious-string-compare bugprone-swapped-arguments bugprone-terminating-continue bugprone-throw-keyword-missing bugprone-too-small-loop-variable bugprone-unchecked-optional-access bugprone-undefined-memory-manipulation bugprone-undelegated-constructor bugprone-unhandled-exception-at-new bugprone-unhandled-self-assignment bugprone-unused-raii bugprone-virtual-near-miss

    Adding these checks makes the code more secure and helps to catch bugs and errors early. It also avoids reviewers to manually check for these issues during reviews.

    I think we should enable the remaining bugprone-* checks but they require much more refactoring so it may be better to enable them in follow-ups PRs.

  2. aureleoules force-pushed on Aug 4, 2022
  3. aureleoules force-pushed on Aug 4, 2022
  4. aureleoules force-pushed on Aug 4, 2022
  5. DrahtBot commented at 4:15 AM on August 5, 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:

    • #25830 (refactor: Replace m_params with chainman.GetParams() by aureleoules)
    • #25172 (refactor: use std:: prefix for std lib funcs by fanquake)

    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.

  6. DrahtBot added the label Needs rebase on Aug 30, 2022
  7. tidy: Explicitly check nullptr
    Fixes 'bugprone-bool-pointer-implicit-conversion'
    aebdca0b1e
  8. tidy: Ignore test case
    Fixes 'bugprone-string-literal-with-embedded-null'
    18013bda53
  9. qt: Fix inaccurate erase
    Fixes 'bugprone-inaccurate-erase'
    6ca25e9498
  10. wallet: Fix string constructor invalid length
    Fixes 'bugprone-string-constructor'
    0ef8161160
  11. test: Fix too small type for loop variable
    Fixes 'bugprone-too-small-loop-variable'
    e7712a387a
  12. test: Handle self-assignment properly
    Fixes 'bugprone-unhandled-self-assignment'
    be43a2d26b
  13. tidy: Ignore warning .c #include
    Fixes 'bugprone-suspicious-include'
    1b3a4a8f02
  14. refactor: Explicitly compare memcmp result
    Fixes 'bugprone-suspicious-string-compare'
    9aecf75c60
  15. refactor: Use correct rounding
    Fixes 'bugprone-incorrect-roundings'
    de2e680ee9
  16. tidy: Ignore 2 'bugprone-sizeof-expression' cases
    Fixes 'bugprone-sizeof-expression'
    39b67f0e37
  17. tidy: Ignore 2 test cases
    Fixes 'bugprone-suspicious-missing-comma'
    80c0fb8a62
  18. refactor: Fix 2 'bugprone-signed-char-misuse' cases
    Fixes 'bugprone-signed-char-misuse'
    e0b39d513a
  19. tidy: Ignore 2 'bugprone-unused-return-value' cases
    Fixes 'bugprone-unused-return-value'
    d1e499035b
  20. tidy: Enable bugprone checks
    Checks enabled:
    bugprone-argument-comment
    bugprone-assert-side-effect
    bugprone-assignment-in-if-condition
    bugprone-bad-signal-to-kill-thread
    bugprone-bool-pointer-implicit-conversion
    bugprone-copy-constructor-init
    bugprone-dangling-handle
    bugprone-dynamic-static-initializers
    bugprone-fold-init-type
    bugprone-forward-declaration-namespace
    bugprone-forwarding-reference-overload
    bugprone-inaccurate-erase
    bugprone-incorrect-roundings
    bugprone-infinite-loop
    bugprone-macro-repeated-side-effects
    bugprone-misplaced-operator-in-strlen-in-alloc
    bugprone-misplaced-pointer-arithmetic-in-alloc
    bugprone-move-forwarding-reference
    bugprone-multiple-statement-macro
    bugprone-no-escape
    bugprone-not-null-terminated-result
    bugprone-parent-virtual-call
    bugprone-posix-return
    bugprone-redundant-branch-condition
    bugprone-shared-ptr-array-mismatch
    bugprone-signal-handler
    bugprone-sizeof-container
    bugprone-sizeof-expression
    bugprone-spuriously-wake-up-functions
    bugprone-string-constructor
    bugprone-string-integer-assignment
    bugprone-string-literal-with-embedded-nul
    bugprone-stringview-nullptr
    bugprone-suspicious-enum-usage
    bugprone-suspicious-include
    bugprone-suspicious-memory-comparison
    bugprone-suspicious-memset-usage
    bugprone-suspicious-missing-comma
    bugprone-suspicious-semicolon
    bugprone-suspicious-string-compare
    bugprone-swapped-arguments
    bugprone-terminating-continue
    bugprone-throw-keyword-missing
    bugprone-too-small-loop-variable
    bugprone-unchecked-optional-access
    bugprone-undefined-memory-manipulation
    bugprone-undelegated-constructor
    bugprone-unhandled-exception-at-new
    bugprone-unhandled-self-assignment
    bugprone-unused-raii
    bugprone-virtual-near-miss
    c80038eea4
  21. aureleoules force-pushed on Sep 5, 2022
  22. DrahtBot removed the label Needs rebase on Sep 5, 2022
  23. aureleoules closed this on Oct 12, 2022

  24. aureleoules deleted the branch on Nov 2, 2022
  25. bitcoin locked this on Nov 2, 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-04-21 18:13 UTC

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