Checking memset/memcpy/memmove. Removed false positives

This commit is contained in:
Daniel Marjamäki 2008-04-18 17:18:22 +00:00
parent 70a9fa246c
commit 77389640cf
1 changed files with 5 additions and 3 deletions

View File

@ -477,6 +477,8 @@ void CheckMemset()
type = getstr(tok, 9);
else if (Match(tok, "memset ( & %var% , %num% , sizeof ( struct %type% ) )"))
type = getstr(tok, 10);
else if (Match(tok, "%type% ( %var% , %var% , sizeof ( %type% ) )"))
type = getstr(tok, 8);
// No type defined => The tokens didn't match
if (!(type && type[0]))
@ -485,10 +487,10 @@ void CheckMemset()
// Warn if type is a class..
const char *pattern1[] = {"class","",NULL};
pattern1[1] = type;
if (strcmp("this",getstr(tok,2))==0 || findtoken(tokens,pattern1))
if (findtoken(tokens,pattern1))
{
std::ostringstream ostr;
ostr << FileLine(tok) << ": Using 'memset' on class.";
ostr << FileLine(tok) << ": Using '" << tok->str << "' on class.";
ReportErr(ostr.str());
continue;
}
@ -504,7 +506,7 @@ void CheckMemset()
if (Match(tstruct, "std :: %type% %var% ;"))
{
std::ostringstream ostr;
ostr << FileLine(tok) << ": Using 'memset' on struct that contains a 'std::" << getstr(tstruct,2) << "'";
ostr << FileLine(tok) << ": Using '" << tok->str << "' on struct that contains a 'std::" << getstr(tstruct,2) << "'";
ReportErr(ostr.str());
break;
}