Misra: Add rule 21.7

This commit is contained in:
Daniel Marjamäki 2017-04-15 08:08:17 +02:00
parent 95048527d0
commit a5b3fe3998
2 changed files with 9 additions and 0 deletions

View File

@ -208,3 +208,7 @@ void misra_21_3() {
realloc(10); // 21.3 realloc(10); // 21.3
free(p1); // 21.3 free(p1); // 21.3
} }
void misra_21_7() {
atoi(str); // 21.7
}

View File

@ -669,6 +669,10 @@ def misra_21_5(rawTokens):
if headerToken and headerToken.str == '<signal.h>': if headerToken and headerToken.str == '<signal.h>':
reportError(token, 21, 5) 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:]: if '-verify' in sys.argv[1:]:
VERIFY = True VERIFY = True
@ -745,6 +749,7 @@ for arg in sys.argv[1:]:
if cfgNumber == 1: if cfgNumber == 1:
misra_21_4(data.rawTokens) misra_21_4(data.rawTokens)
misra_21_5(data.rawTokens) misra_21_5(data.rawTokens)
misra_21_7(cfg)
if VERIFY: if VERIFY:
for expected in VERIFY_EXPECTED: for expected in VERIFY_EXPECTED: