From 6c02de151fd4dc550191ff602c0b309483728f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 29 Oct 2011 12:27:19 +0200 Subject: [PATCH] strncmp sizeof: tweaked the check. --- lib/checkother.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b6ef2d584..7ad3a61b6 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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;