From d7b8180495411cbb0f878bb199b16259e7c05f4c Mon Sep 17 00:00:00 2001 From: swasti16 Date: Mon, 3 Feb 2025 20:56:15 +0530 Subject: [PATCH] Fix #13615: False positive: Misra C 17.3: UINT32_C --- addons/misra.py | 3 ++- addons/test/misra/misra-test.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index bbf7e6c558e..0b66935a551 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -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 diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 6e18e7610c5..4e9a1aec08c 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -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