Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #13615: False positive: Misra C 17.3: UINT32_C #7276

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading