@@ -1433,6 +1433,23 @@ def misra_1_4(self, cfg):
14331433 'wcrtomb_s' , 'mbsrtowcs_s' , 'wcsrtombs_s' ):
14341434 self .reportError (token , 1 , 4 )
14351435
1436+ def misra_2_2 (self , cfg ):
1437+ for token in cfg .tokenlist :
1438+ if (token .str in '+-' ) and token .astOperand2 :
1439+ if simpleMatch (token .astOperand1 , '0' ):
1440+ self .reportError (token .astOperand1 , 2 , 2 )
1441+ elif simpleMatch (token .astOperand2 , '0' ):
1442+ self .reportError (token .astOperand2 , 2 , 2 )
1443+ if token .str == '*' and token .astOperand2 :
1444+ if simpleMatch (token .astOperand2 , '0' ):
1445+ self .reportError (token .astOperand1 , 2 , 2 )
1446+ elif simpleMatch (token .astOperand1 , '0' ):
1447+ self .reportError (token .astOperand2 , 2 , 2 )
1448+ elif simpleMatch (token .astOperand1 , '1' ):
1449+ self .reportError (token .astOperand1 , 2 , 2 )
1450+ elif simpleMatch (token .astOperand2 , '1' ):
1451+ self .reportError (token .astOperand2 , 2 , 2 )
1452+
14361453 def misra_2_3 (self , dumpfile , typedefInfo ):
14371454 self ._save_ctu_summary_typedefs (dumpfile , typedefInfo )
14381455
@@ -4227,6 +4244,7 @@ def fillVerifyExpected(verify_expected, tok):
42274244 self .printStatus ('Checking %s, config %s...' % (dumpfile , cfg .name ))
42284245
42294246 self .executeCheck (104 , self .misra_1_4 , cfg )
4247+ self .executeCheck (202 , self .misra_2_2 , cfg )
42304248 self .executeCheck (203 , self .misra_2_3 , dumpfile , cfg .typedefInfo )
42314249 self .executeCheck (204 , self .misra_2_4 , dumpfile , cfg )
42324250 self .executeCheck (205 , self .misra_2_5 , dumpfile , cfg )
0 commit comments