From a5b3fe39981fa2e048956db571aeecaa5c314f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 15 Apr 2017 08:08:17 +0200 Subject: [PATCH] Misra: Add rule 21.7 --- addons/misra-test.c | 4 ++++ addons/misra.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/addons/misra-test.c b/addons/misra-test.c index 7eca926ac..cbc3f112e 100644 --- a/addons/misra-test.c +++ b/addons/misra-test.c @@ -208,3 +208,7 @@ void misra_21_3() { realloc(10); // 21.3 free(p1); // 21.3 } + +void misra_21_7() { + atoi(str); // 21.7 +} diff --git a/addons/misra.py b/addons/misra.py index 67d2a5773..af321edc2 100644 --- a/addons/misra.py +++ b/addons/misra.py @@ -669,6 +669,10 @@ def misra_21_5(rawTokens): if headerToken and headerToken.str == '': reportError(token, 21, 5) +def misra_21_7(data): + for token in data.tokenlist: + if (token.str in ['atof', 'atoi', 'atol', 'atoll']) and token.next and token.next.str == '(': + reportError(token, 21, 7) if '-verify' in sys.argv[1:]: VERIFY = True @@ -745,6 +749,7 @@ for arg in sys.argv[1:]: if cfgNumber == 1: misra_21_4(data.rawTokens) misra_21_5(data.rawTokens) + misra_21_7(cfg) if VERIFY: for expected in VERIFY_EXPECTED: