Skip to content

Conversation

@aureleoules
Copy link
Contributor

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.

@aureleoules aureleoules force-pushed the 2022-08-enable-bugprone-checks branch 3 times, most recently from d3ded83 to 0e37516 Compare August 4, 2022 14:35
@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 5, 2022

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

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.

Fixes 'bugprone-bool-pointer-implicit-conversion'
Fixes 'bugprone-string-literal-with-embedded-null'
Fixes 'bugprone-inaccurate-erase'
Fixes 'bugprone-string-constructor'
Fixes 'bugprone-too-small-loop-variable'
Fixes 'bugprone-unhandled-self-assignment'
Fixes 'bugprone-suspicious-include'
Fixes 'bugprone-suspicious-string-compare'
Fixes 'bugprone-incorrect-roundings'
Fixes 'bugprone-sizeof-expression'
Fixes 'bugprone-suspicious-missing-comma'
Fixes 'bugprone-signed-char-misuse'
Fixes 'bugprone-unused-return-value'
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
@aureleoules aureleoules force-pushed the 2022-08-enable-bugprone-checks branch from 0e37516 to c80038e Compare September 5, 2022 09:49
@aureleoules aureleoules deleted the 2022-08-enable-bugprone-checks branch November 2, 2022 10:51
@bitcoin bitcoin locked and limited conversation to collaborators Nov 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants