Misra: Add rule 21.8

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

View File

@ -210,5 +210,14 @@ void misra_21_3() {
}
void misra_21_7() {
atof(str); // 21.7
atoi(str); // 21.7
atol(str); // 21.7
atoll(str); // 21.7
}
void misra_21_8() {
abort(); // 21.8
getenv("foo"); // 21.8
system(""); // 21.8
}

View File

@ -674,6 +674,11 @@ def misra_21_7(data):
if (token.str in ['atof', 'atoi', 'atol', 'atoll']) and token.next and token.next.str == '(':
reportError(token, 21, 7)
def misra_21_8(data):
for token in data.tokenlist:
if (token.str in ['abort', 'getenv', 'system']) and token.next and token.next.str == '(':
reportError(token, 21, 8)
if '-verify' in sys.argv[1:]:
VERIFY = True
@ -750,6 +755,7 @@ for arg in sys.argv[1:]:
misra_21_4(data.rawTokens)
misra_21_5(data.rawTokens)
misra_21_7(cfg)
misra_21_8(cfg)
if VERIFY:
for expected in VERIFY_EXPECTED: