File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -494,9 +494,12 @@ void CheckUnsignedDivision()
494494 TOKEN *tokdiv = findtoken (declvar, pattern_div1);
495495 while ( tokdiv )
496496 {
497- std::ostringstream ostr;
498- ostr << FileLine (tokdiv) << " : If the result is negative it will be wrong because an operand is unsigned." ;
499- ReportErr (ostr.str ());
497+ if ( strcmp (getstr (tokdiv,2 ), " ->" ) )
498+ {
499+ std::ostringstream ostr;
500+ ostr << FileLine (tokdiv) << " : If the result is negative it will be wrong because an operand is unsigned." ;
501+ ReportErr (ostr.str ());
502+ }
500503 tokdiv = findtoken (tokdiv->next , pattern_div1);
501504 }
502505
@@ -505,7 +508,9 @@ void CheckUnsignedDivision()
505508 tokdiv = findtoken (declvar, pattern_div2);
506509 while ( tokdiv )
507510 {
508- if (!IsNumber (getstr (tokdiv,3 )) && tokdiv->str [0 ]!=' )' ) // The ')' may indicate a cast
511+ if (!IsNumber (getstr (tokdiv,3 )) &&
512+ tokdiv->str [0 ] != ' )' && // The ')' may indicate a cast
513+ strcmp (tokdiv->str ," ->" ))
509514 {
510515 std::ostringstream ostr;
511516 ostr << FileLine (tokdiv) << " : If the result is negative it will be wrong because an operand is unsigned." ;
Original file line number Diff line number Diff line change @@ -223,6 +223,10 @@ void CreateStatementList()
223223 ismalloc |= match (rs, " ( type * * ) malloc (" );
224224 ismalloc |= match (rs, " ( type type * ) malloc (" );
225225 ismalloc |= match (rs, " ( type type * * ) malloc (" );
226+ ismalloc |= match (rs, " ( type * ) kmalloc (" );
227+ ismalloc |= match (rs, " ( type * * ) kmalloc (" );
228+ ismalloc |= match (rs, " ( type type * ) kmalloc (" );
229+ ismalloc |= match (rs, " ( type type * * ) kmalloc (" );
226230 }
227231
228232 if ( ismalloc )
@@ -253,6 +257,9 @@ void CreateStatementList()
253257 if (match (tok2, " free ( var ) ;" ))
254258 AppendStatement (STATEMENT ::FREE , tok2, getstr (tok2, 2 ));
255259
260+ if (match (tok2, " kfree ( var ) ;" ))
261+ AppendStatement (STATEMENT ::FREE , tok2, getstr (tok2, 2 ));
262+
256263 if (match (tok2, " delete var ;" ))
257264 AppendStatement (STATEMENT ::DELETE , tok2, getstr (tok2,1 ));
258265
Original file line number Diff line number Diff line change @@ -219,9 +219,6 @@ static void CppCheck(const char FileName[])
219219 // Dangerous usage of strtok
220220 // Disabled because it generates false positives
221221 // WarningStrTok();
222-
223- // Variable scope
224- CheckVariableScope ();
225222 }
226223
227224
@@ -262,6 +259,9 @@ static void CppCheck(const char FileName[])
262259
263260 // if (condition);
264261 WarningIf ();
262+
263+ // Variable scope
264+ CheckVariableScope ();
265265 }
266266
267267
You can’t perform that action at this time.
0 commit comments