Skip to content

Commit

Permalink
Fix #13615: False positive: Misra C 17.3: UINT32_C
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti16 committed Feb 3, 2025
1 parent 4e59e90 commit d7b8180
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3338,7 +3338,8 @@ def misra_17_3(self, cfg):
end_token = token.next.link
while tok != end_token:
if tok.isName and tok.function is None and tok.valueType is None and tok.next.str == "(" and \
tok.next.valueType is None and not isKeyword(tok.str) and not isStdLibId(tok.str):
tok.next.valueType is None and not isKeyword(tok.str) and not isStdLibId(tok.str) and \
not re.match(r'U?INT(_MAX|)(8|16|32|64)_C', tok.str):
self.reportError(tok, 17, 3)
break
tok = tok.next
Expand Down
4 changes: 4 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,10 @@ static void misra_17_3(void) {
if (dostuff()) {}
}

static void misra_17_3_compliant(uint32_t x) {
if (x == UINT32_C(1)){ } // no warning for 17_3
}

static void misra_config(const char* str) {
if (strlen(str) > 3){} //10.4
if (sizeof(int) > 1){} //10.4
Expand Down

0 comments on commit d7b8180

Please sign in to comment.