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);
|
TOKEN *tokdiv = findtoken(declvar, pattern_div1);
|
||||||
while ( tokdiv )
|
while ( tokdiv )
|
||||||
{
|
{
|
||||||
std::ostringstream ostr;
|
if ( strcmp(getstr(tokdiv,2), "->") )
|
||||||
ostr << FileLine(tokdiv) << ": If the result is negative it will be wrong because an operand is unsigned.";
|
{
|
||||||
ReportErr(ostr.str());
|
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);
|
tokdiv = findtoken(tokdiv->next, pattern_div1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -505,7 +508,9 @@ void CheckUnsignedDivision()
|
||||||
tokdiv = findtoken(declvar, pattern_div2);
|
tokdiv = findtoken(declvar, pattern_div2);
|
||||||
while ( tokdiv )
|
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;
|
std::ostringstream ostr;
|
||||||
ostr << FileLine(tokdiv) << ": If the result is negative it will be wrong because an operand is unsigned.";
|
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 * * ) malloc (");
|
||||||
ismalloc |= match(rs, "( type type * ) malloc (");
|
ismalloc |= match(rs, "( type 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 )
|
if ( ismalloc )
|
||||||
|
@ -253,6 +257,9 @@ void CreateStatementList()
|
||||||
if (match(tok2, "free ( var ) ;"))
|
if (match(tok2, "free ( var ) ;"))
|
||||||
AppendStatement(STATEMENT::FREE, tok2, getstr(tok2, 2));
|
AppendStatement(STATEMENT::FREE, tok2, getstr(tok2, 2));
|
||||||
|
|
||||||
|
if (match(tok2, "kfree ( var ) ;"))
|
||||||
|
AppendStatement(STATEMENT::FREE, tok2, getstr(tok2, 2));
|
||||||
|
|
||||||
if (match(tok2, "delete var ;"))
|
if (match(tok2, "delete var ;"))
|
||||||
AppendStatement(STATEMENT::DELETE, tok2, getstr(tok2,1));
|
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
|
// Dangerous usage of strtok
|
||||||
// Disabled because it generates false positives
|
// Disabled because it generates false positives
|
||||||
//WarningStrTok();
|
//WarningStrTok();
|
||||||
|
|
||||||
// Variable scope
|
|
||||||
CheckVariableScope();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,6 +259,9 @@ static void CppCheck(const char FileName[])
|
||||||
|
|
||||||
// if (condition);
|
// if (condition);
|
||||||
WarningIf();
|
WarningIf();
|
||||||
|
|
||||||
|
// Variable scope
|
||||||
|
CheckVariableScope();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue