Skip to content

Fix 13143: False positive: misra 14.1 (i < n) && (x[i] > last)#6838

Merged
danmar merged 1 commit intocppcheck-opensource:mainfrom
swasti16:swasti/13143
Oct 5, 2024
Merged

Fix 13143: False positive: misra 14.1 (i < n) && (x[i] > last)#6838
danmar merged 1 commit intocppcheck-opensource:mainfrom
swasti16:swasti/13143

Conversation

@swasti16
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread addons/misra.py Outdated
Comment thread addons/test/misra/misra-test.c Outdated
Comment thread addons/misra.py Outdated
@swasti16 swasti16 force-pushed the swasti/13143 branch 2 times, most recently from 0cdfccf to effbc08 Compare October 2, 2024 16:08
Comment thread addons/misra.py Outdated
if not counterToken.valueType or not counterToken.valueType.isFloat():
continue
if token.isAssignmentOp and token.astOperand1.str == counterToken.str:
if token.str not in tok_str:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm the old code only matched the token string but that is unfortunate.

we should not determine that f is a loop counter here:

void foo(void)
{
    int i = 0;
    float f = 0;
    while (f < 10 && i < 10) {
        float f = 0; f = f + i;
        i++;
    }
}

@danmar danmar merged commit 4fba1e3 into cppcheck-opensource:main Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants