Skip to content

Commit e101425

Browse files
hcorgdanmar
authored andcommitted
MISRA Rule 11.6 will no longer report violation on '(void)p;' (#1272)
1 parent cc77a6a commit e101425

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

addons/misra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ def misra_11_6(data):
901901
continue
902902
if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.str != "0":
903903
reportError(token, 11, 6)
904-
elif vt1.pointer == 0 and vt2.pointer == 1 and vt2.type == 'void':
904+
elif vt1.pointer == 0 and vt1.type != 'void' and vt2.pointer == 1 and vt2.type == 'void':
905905
reportError(token, 11, 6)
906906

907907

addons/test/misra-test.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ void misra_11_5(void *p) {
196196

197197
void misra_11_6() {
198198
void *p;
199-
p = (void*)123; // 11.6
200-
x = (u64)p; // 11.6
201-
p = ( void * )0 // no-warning
199+
p = (void*)123; // 11.6
200+
x = (u64)p; // 11.6
201+
p = ( void * )0; // no-warning
202+
(void)p; // no-warning
202203
}
203204

204205

0 commit comments

Comments
 (0)