Updates here and there to make it more accurate
This commit is contained in:
parent
85a50103a5
commit
b1b7593c76
|
@ -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.";
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
6
main.cpp
6
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue