From ebf54ac53e81c2b11a80dd5f51bcb57ba90b9b0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 25 Feb 2021 22:11:13 +0100 Subject: [PATCH] Misra; Remove 12.4 because the check is not implemented properly --- addons/misra.py | 21 --------------------- addons/test/misra/misra-test.c | 8 ++++---- 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/addons/misra.py b/addons/misra.py index 5d27c700a..6ff5a5f13 100755 --- a/addons/misra.py +++ b/addons/misra.py @@ -1876,26 +1876,6 @@ class MisraChecker: break prev = prev.previous - def misra_12_4(self, data): - if typeBits['INT'] == 16: - max_uint = 0xffff - elif typeBits['INT'] == 32: - max_uint = 0xffffffff - else: - return - - for token in data.tokenlist: - if not token.values: - continue - if (not isConstantExpression(token)) or (not isUnsignedInt(token)): - continue - for value in token.values: - if value.intvalue is None: - continue - if value.intvalue < 0 or value.intvalue > max_uint: - self.reportError(token, 12, 4) - break - def misra_13_1(self, data): for token in data.tokenlist: if simpleMatch(token, ") {") and token.next.astParent == token.link: @@ -3141,7 +3121,6 @@ class MisraChecker: self.executeCheck(1201, self.misra_12_1, cfg) self.executeCheck(1202, self.misra_12_2, cfg) self.executeCheck(1203, self.misra_12_3, cfg) - self.executeCheck(1204, self.misra_12_4, cfg) self.executeCheck(1301, self.misra_13_1, cfg) self.executeCheck(1303, self.misra_13_3, cfg) self.executeCheck(1304, self.misra_13_4, cfg) diff --git a/addons/test/misra/misra-test.c b/addons/test/misra/misra-test.c index 5b8a2034f..d0c763af2 100644 --- a/addons/test/misra/misra-test.c +++ b/addons/test/misra/misra-test.c @@ -732,10 +732,10 @@ void misra_12_3(int a, int b, int c) { // no warning void misra_12_4() { uint32_t x; bool t; - x = 123456u * 123456u; // 12.4 - x = MISRA12_4a + MISRA12_4b; // 12.4 - x = 0u - 1u; // 12.4 - x = t ? 0u : (0u-1u); // 12.4 + x = 123456u * 123456u; // TODO 12.4 + x = MISRA12_4a + MISRA12_4b; // TODO 12.4 + x = 0u - 1u; // TODO 12.4 + x = t ? 0u : (0u-1u); // TODO 12.4 x = 556200230913ULL; foo(&volatile_macro_12_4); // no crash }