misra; implement rule 21.15
This commit is contained in:
parent
6a81b4c17c
commit
f85f3c28e1
|
@ -1287,6 +1287,8 @@ def get_function_call_name_args(token):
|
||||||
return None, None
|
return None, None
|
||||||
if token.function:
|
if token.function:
|
||||||
nametok = token.function.token
|
nametok = token.function.token
|
||||||
|
if nametok is None:
|
||||||
|
nametok = token.function.tokenDef
|
||||||
if token in (token.function.token, token.function.tokenDef):
|
if token in (token.function.token, token.function.tokenDef):
|
||||||
return None, None
|
return None, None
|
||||||
name = nametok.str
|
name = nametok.str
|
||||||
|
|
|
@ -3429,6 +3429,23 @@ class MisraChecker:
|
||||||
'fetestexcept')):
|
'fetestexcept')):
|
||||||
self.reportError(token, 21, 12)
|
self.reportError(token, 21, 12)
|
||||||
|
|
||||||
|
def misra_21_15(self, data):
|
||||||
|
for token in data.tokenlist:
|
||||||
|
if token.str not in ('memcpy', 'memmove', 'memcmp'):
|
||||||
|
continue
|
||||||
|
name, args = cppcheckdata.get_function_call_name_args(token)
|
||||||
|
if name is None:
|
||||||
|
continue
|
||||||
|
if len(args) != 3:
|
||||||
|
continue
|
||||||
|
if args[0].valueType is None or args[1].valueType is None:
|
||||||
|
continue
|
||||||
|
if args[0].valueType.type == args[1].valueType.type:
|
||||||
|
continue
|
||||||
|
if args[0].valueType.type == 'void' or args[1].valueType.type == 'void':
|
||||||
|
continue
|
||||||
|
self.reportError(token, 21, 15)
|
||||||
|
|
||||||
def misra_22_5(self, cfg):
|
def misra_22_5(self, cfg):
|
||||||
for token in cfg.tokenlist:
|
for token in cfg.tokenlist:
|
||||||
if token.isUnaryOp("*") or (token.isBinaryOp() and token.str == '.'):
|
if token.isUnaryOp("*") or (token.isBinaryOp() and token.str == '.'):
|
||||||
|
@ -4002,6 +4019,7 @@ class MisraChecker:
|
||||||
self.executeCheck(2110, self.misra_21_10, cfg)
|
self.executeCheck(2110, self.misra_21_10, cfg)
|
||||||
self.executeCheck(2111, self.misra_21_11, cfg)
|
self.executeCheck(2111, self.misra_21_11, cfg)
|
||||||
self.executeCheck(2112, self.misra_21_12, cfg)
|
self.executeCheck(2112, self.misra_21_12, cfg)
|
||||||
|
self.executeCheck(2115, self.misra_21_15, cfg)
|
||||||
# 22.4 is already covered by Cppcheck writeReadOnlyFile
|
# 22.4 is already covered by Cppcheck writeReadOnlyFile
|
||||||
self.executeCheck(2205, self.misra_22_5, cfg)
|
self.executeCheck(2205, self.misra_22_5, cfg)
|
||||||
|
|
||||||
|
|
|
@ -1641,6 +1641,12 @@ static void misra_21_12(void) {
|
||||||
rc = fetestexcept(1); // 21.12
|
rc = fetestexcept(1); // 21.12
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void misra_21_15(uint8_t *x, uint16_t *y) {
|
||||||
|
(void)memcpy(x, y, 10); // 21.15
|
||||||
|
(void)memmove(x, y, 10); // 21.15
|
||||||
|
(void)memcmp(x, y, 10); // 21.15
|
||||||
|
}
|
||||||
|
|
||||||
// Large arrays for R13.1. Size exceeds default Python's max recursion depth.
|
// Large arrays for R13.1. Size exceeds default Python's max recursion depth.
|
||||||
static uint8_t misra_13_1_large_ok[1024] = {
|
static uint8_t misra_13_1_large_ok[1024] = {
|
||||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||||
|
|
Loading…
Reference in New Issue