fix: enforce MISRA compliant Boolean values#2312
Closed
AgentsLogic wants to merge 1 commit intocommaai:masterfrom
Closed
fix: enforce MISRA compliant Boolean values#2312AgentsLogic wants to merge 1 commit intocommaai:masterfrom
AgentsLogic wants to merge 1 commit intocommaai:masterfrom
Conversation
- Replace integer assignments to bools with true/false - safety_tx_blocked = 0 -> false - safety_rx_invalid = 0 -> false - led_set(LED_RED, 1) -> led_set(LED_RED, true) - led_set(LED_RED, 0) -> led_set(LED_RED, false) - Add cppcheck patch for enforcing MISRA compliant Boolean values - Patch implements CheckBool::checkAssignedLiteralToBoolean check - Detects and reports integer-to-bool assignments - Ref: danmar/cppcheck#7110 - Update install.sh to apply the patch during cppcheck build - Patch is applied after checking out cppcheck 2.16.0 - Gracefully handles case where patch is already applied Fixes issue commaai#2105
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the fix for issue #2105 by:
Fixing all integer-to-bool violations in board/main.c:
safety_tx_blocked = 0→safety_tx_blocked = falsesafety_rx_invalid = 0→safety_rx_invalid = falseled_set(LED_RED, 1)→led_set(LED_RED, true)led_set(LED_RED, 0)→led_set(LED_RED, false)Adding cppcheck patch for enforcing MISRA compliant Boolean values:
CheckBool::checkAssignedLiteralToBooleancheck from upstream PR feat: enforcing MISRA compliant Boolean values danmar/cppcheck#7110tests/misra/install.shTesting:
Changes
board/main.c: Replace integer literals with boolean literalstests/misra/install.sh: Apply cppcheck patch after checkouttests/misra/0001-feat-enforcing-MISRA-compliant-Boolean-values.patch: Patch file for cppcheckFixes #2105