Skip to content

Commit

Permalink
Fix 12448: False positive: misra-config about unknown variable after …
Browse files Browse the repository at this point in the history
…struct keyword (#5991)
  • Loading branch information
swasti16 committed Feb 18, 2024
1 parent f06b989 commit 8050448
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3327,6 +3327,9 @@ def misra_config(self, data):
end_token = tok.link
while tok != end_token:
tok = tok.next
if tok.str == 'sizeof' and tok.next.str == '(':
tok = tok.next.link
continue
if tok.str == "(" and tok.isCast:
tok = tok.link
continue
Expand Down Expand Up @@ -4254,6 +4257,7 @@ def setSuppressionList(self, suppressionlist):
self.addSuppressedRule(ruleNum)

def report_config_error(self, location, errmsg):
errmsg = 'Because of missing configuration, misra checking is incomplete. There can be false negatives! ' + errmsg
cppcheck_severity = 'error'
error_id = 'config'
if self.settings.verify:
Expand Down
10 changes: 10 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,3 +2035,13 @@ static void misra_22_10(void)
f = strtod(inStr, NULL_PTR);
if(errno != 0) {}
}

// #12448
static void check_misra_config(void)
{
if (sizeof(struct bar) == 0U) {} //no warning
if (sizeof(int abc) == 0U) {} //no warning
if (sizeof(xyz) == 0U) {} //no warning
if (sizeof(const pqr) == 0U) {} //no warning
if (sizeof(const int* const pqrs) == 0U) {} //no-warning
}

0 comments on commit 8050448

Please sign in to comment.