Updates here and there to make it more accurate

This commit is contained in:
Daniel Marjamäki 2008-03-19 06:03:56 +00:00
parent 85a50103a5
commit b1b7593c76
3 changed files with 19 additions and 7 deletions

View File

@ -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.";

View File

@ -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));

View File

@ -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();
}