Fix FPs for unsigned operations in INT30-C and RULE-8-20-1#1140
Open
mbaluda wants to merge 4 commits into
Open
Fix FPs for unsigned operations in INT30-C and RULE-8-20-1#1140mbaluda wants to merge 4 commits into
INT30-C and RULE-8-20-1#1140mbaluda wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to reduce false positives for unsigned division/remainder compound assignments (/= and %=) in the shared “unsigned operation with constant operands wraps” logic, which is reused by INT30-C and RULE-8-20-1.
Changes:
- Update the shared query predicate to exclude all division/remainder operations via
DivOrRemOperation(including assignment forms). - Add new C and C++ test cases marking
/,/=,%, and%=as COMPLIANT under exception 2. - Add a change note documenting the FP fix for both affected rules.
Review checklist items uncertain / not verified in this automated review:
- Running the shared queries in VS Code to confirm output format validity.
- Performance/results validation on OpenPilot.
Show a summary per file
| File | Description |
|---|---|
cpp/common/src/codingstandards/cpp/rules/unsignedoperationwithconstantoperandswraps/UnsignedOperationWithConstantOperandsWraps.qll |
Broadens the exception-2 exclusion to cover division/remainder compound assignments via DivOrRemOperation. |
cpp/common/test/rules/unsignedoperationwithconstantoperandswraps/test.cpp |
Adds /, /=, %, %= COMPLIANT tests (currently introduced in a way that breaks compilation; see PR comments). |
c/common/test/rules/unsignedoperationwithconstantoperandswraps/test.c |
Mirrors the C++ test additions (currently introduced in a way that breaks compilation; see PR comments). |
change_notes/2026-06-18-fix-fp-misra-c++-8-20-1.md |
Documents the FP fix for INT30-C and RULE-8-20-1. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 2
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Description
This pull request addresses false positives in the detection of unsigned integer operations that may wrap around, specifically for division and remainder assignments (
/=and%=), and updates relevant tests and documentation. The main changes include refining the logic in the query to group division and remainder operations, updating test cases to reflect compliant usage, and documenting the fixes.Change request type
.ql,.qll,.qlsor unit tests)Rules with added or modified queries
Release change checklist
A change note (development_handbook.md#change-notes) is required for any pull request which modifies:
If you are only adding new rule queries, a change note is not required.
Author: Is a change note required?
🚨🚨🚨
Reviewer: Confirm that format of shared queries (not the .qll file, the
.ql file that imports it) is valid by running them within VS Code.
Reviewer: Confirm that either a change note is not required or the change note is required and has been added.
Query development review checklist
For PRs that add new queries or modify existing queries, the following checklist should be completed by both the author and reviewer:
Author
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.
Reviewer
As a rule of thumb, predicates specific to the query should take no more than 1 minute, and for simple queries be under 10 seconds. If this is not the case, this should be highlighted and agreed in the code review process.