Skip to content

Commit

Permalink
Fix #12184: false positive: misra 11.6, cast expression '0U' to 'void…
Browse files Browse the repository at this point in the history
…*' (danmar#5666)
  • Loading branch information
swasti16 authored Nov 16, 2023
1 parent ae3f7bd commit 81a03e7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2562,7 +2562,7 @@ def misra_11_6(self, data):
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)
Expand Down
2 changes: 2 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}


Expand Down

0 comments on commit 81a03e7

Please sign in to comment.