From 81a03e734117048b59cc752b1c5452c301f55877 Mon Sep 17 00:00:00 2001 From: Swasti Shrivastava <37058682+swasti16@users.noreply.github.com> Date: Thu, 16 Nov 2023 13:36:58 +0530 Subject: [PATCH] Fix #12184: false positive: misra 11.6, cast expression '0U' to 'void*' (#5666) --- addons/misra.py | 2 +- addons/test/misra/misra-test.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/misra.py b/addons/misra.py index 48b6e0a59..6f38ec069 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -2562,7 +2562,7 @@ class MisraChecker: vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue - if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.str != "0": + if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.getKnownIntValue() != 0: self.reportError(token, 11, 6) elif vt1.pointer == 0 and vt1.type != 'void' and vt2.pointer == 1 and vt2.type == 'void': self.reportError(token, 11, 6) diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index ebce42587..790c7a0da 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -811,6 +811,8 @@ static void misra_11_6(void) { x = (u64)p; // 11.6 p = ( void * )0; // no-warning (void)p; // no-warning + // # 12184 + p = (void*)0U; // no-warning }