MISRA: Prevent exception on variadic functions (#1436)
Functions with variadic arguments trip an exception in the MISRA checker because some of the token is None and does not have some of the members the code is expecting. Prevent this by checking to see if the token is None and skipping the code that tries to use that value.
This commit is contained in:
parent
b31b4706c5
commit
4dbdc934b8
|
@ -618,6 +618,7 @@ class MisraChecker:
|
|||
def misra_5_2(self, data):
|
||||
scopeVars = {}
|
||||
for var in data.variables:
|
||||
if var.nameToken is not None:
|
||||
if var.nameToken.scope not in scopeVars:
|
||||
scopeVars.setdefault(var.nameToken.scope, {})["varlist"] = []
|
||||
scopeVars.setdefault(var.nameToken.scope, {})["scopelist"] = []
|
||||
|
@ -664,6 +665,7 @@ class MisraChecker:
|
|||
enum = []
|
||||
scopeVars = {}
|
||||
for var in data.variables:
|
||||
if var.nameToken is not None:
|
||||
if var.nameToken.scope not in scopeVars:
|
||||
scopeVars[var.nameToken.scope] = []
|
||||
scopeVars[var.nameToken.scope].append(var)
|
||||
|
@ -760,6 +762,7 @@ class MisraChecker:
|
|||
macroNames.append(res.group(1))
|
||||
for var in data.variables:
|
||||
for macro in macroNames:
|
||||
if var.nameToken is not None:
|
||||
if var.nameToken.str[:31] == macro[:31]:
|
||||
self.reportError(var.nameToken, 5, 5)
|
||||
for scope in data.scopes:
|
||||
|
|
Loading…
Reference in New Issue