From c73dc635373138acd5abb6fe66a3b58cd7c0f6c6 Mon Sep 17 00:00:00 2001 From: Swasti Shrivastava <37058682+swasti16@users.noreply.github.com> Date: Tue, 22 May 2018 18:02:00 +0530 Subject: [PATCH] Modified rule 11.5 (#1256) --- addons/misra.py | 9 +++++++++ addons/test/misra-test.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/addons/misra.py b/addons/misra.py index 9f75874d2..2a79f40d4 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -802,6 +802,15 @@ def misra_11_4(data): def misra_11_5(data): for token in data.tokenlist: if not isCast(token): + if token.str == "=" and token.next.str != "(": + vt1 = token.astOperand1.valueType + vt2 = token.astOperand2.valueType + if not vt1 or not vt2: + continue + if vt1.pointer > 0 and vt1.type != 'void' and vt2.pointer == vt1.pointer and vt2.type == 'void': + reportError(token, 11, 5) + continue + if token.astOperand1.astOperand1 and token.astOperand1.astOperand1.str in {'malloc', 'calloc', 'realloc', 'free'}: continue vt1 = token.valueType vt2 = token.astOperand1.valueType diff --git a/addons/test/misra-test.c b/addons/test/misra-test.c index 9b4fd2d85..3f56a78c1 100644 --- a/addons/test/misra-test.c +++ b/addons/test/misra-test.c @@ -179,7 +179,9 @@ void misra_11_4(u8*p) { } void misra_11_5(void *p) { + u16 *p16; x = (u8 *)p; // 11.5 + p16 = p; //11.5 } void misra_11_6() {