diff --git a/CheckOther.cpp b/CheckOther.cpp index bfc87bec3..314ab315f 100644 --- a/CheckOther.cpp +++ b/CheckOther.cpp @@ -494,9 +494,12 @@ void CheckUnsignedDivision() TOKEN *tokdiv = findtoken(declvar, pattern_div1); while ( tokdiv ) { - std::ostringstream ostr; - ostr << FileLine(tokdiv) << ": If the result is negative it will be wrong because an operand is unsigned."; - ReportErr(ostr.str()); + if ( strcmp(getstr(tokdiv,2), "->") ) + { + std::ostringstream ostr; + ostr << FileLine(tokdiv) << ": If the result is negative it will be wrong because an operand is unsigned."; + ReportErr(ostr.str()); + } tokdiv = findtoken(tokdiv->next, pattern_div1); } @@ -505,7 +508,9 @@ void CheckUnsignedDivision() tokdiv = findtoken(declvar, pattern_div2); while ( tokdiv ) { - if (!IsNumber(getstr(tokdiv,3)) && tokdiv->str[0]!=')') // The ')' may indicate a cast + if (!IsNumber(getstr(tokdiv,3)) && + tokdiv->str[0] != ')' && // The ')' may indicate a cast + strcmp(tokdiv->str,"->")) { std::ostringstream ostr; ostr << FileLine(tokdiv) << ": If the result is negative it will be wrong because an operand is unsigned."; diff --git a/Statements.cpp b/Statements.cpp index 29851d3b2..0aca8b271 100644 --- a/Statements.cpp +++ b/Statements.cpp @@ -223,6 +223,10 @@ void CreateStatementList() ismalloc |= match(rs, "( type * * ) malloc ("); ismalloc |= match(rs, "( type type * ) malloc ("); ismalloc |= match(rs, "( type type * * ) malloc ("); + ismalloc |= match(rs, "( type * ) kmalloc ("); + ismalloc |= match(rs, "( type * * ) kmalloc ("); + ismalloc |= match(rs, "( type type * ) kmalloc ("); + ismalloc |= match(rs, "( type type * * ) kmalloc ("); } if ( ismalloc ) @@ -253,6 +257,9 @@ void CreateStatementList() if (match(tok2, "free ( var ) ;")) AppendStatement(STATEMENT::FREE, tok2, getstr(tok2, 2)); + if (match(tok2, "kfree ( var ) ;")) + AppendStatement(STATEMENT::FREE, tok2, getstr(tok2, 2)); + if (match(tok2, "delete var ;")) AppendStatement(STATEMENT::DELETE, tok2, getstr(tok2,1)); diff --git a/main.cpp b/main.cpp index 0c8fe3c0e..6f8e42837 100644 --- a/main.cpp +++ b/main.cpp @@ -219,9 +219,6 @@ static void CppCheck(const char FileName[]) // Dangerous usage of strtok // Disabled because it generates false positives //WarningStrTok(); - - // Variable scope - CheckVariableScope(); } @@ -262,6 +259,9 @@ static void CppCheck(const char FileName[]) // if (condition); WarningIf(); + + // Variable scope + CheckVariableScope(); }