strncmp sizeof: tweaked the check.

This commit is contained in:
Daniel Marjamäki 2011-10-29 12:27:19 +02:00
parent 3d438003ff
commit 6c02de151f
1 changed files with 8 additions and 2 deletions

View File

@ -422,8 +422,14 @@ void CheckOther::sizeofForArrayParameterError(const Token *tok)
void CheckOther::checkSizeofForStrncmpSize()
{
const SymbolDatabase *symbolDatabase = _tokenizer->getSymbolDatabase();
const char pattern1[] = "strncmp ( %any , %any% , sizeof ( %var% ) )";
const char pattern2[] = "strncmp ( %any , %any% , sizeof %var% )";
const char pattern1[] = "strncmp ( %any% , %any% , sizeof ( %var% ) )";
const char pattern2[] = "strncmp ( %any% , %any% , sizeof %var% )";
// this check is inconclusive - it might be intentional to use
// sizeof(char *) as parameter
if (!_settings->inconclusive)
return;
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
if (Token::Match(tok, pattern1) || Token::Match(tok, pattern2)) {
int tokIdx = 7;