From 77389640cf38892f12eaf6b11ce5a0d837c2ccaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 18 Apr 2008 17:18:22 +0000 Subject: [PATCH] Checking memset/memcpy/memmove. Removed false positives --- CheckClass.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CheckClass.cpp b/CheckClass.cpp index d639352e5..7e210c4d7 100644 --- a/CheckClass.cpp +++ b/CheckClass.cpp @@ -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; }