Add strncmp to the list of static string comparison functions
This commit is contained in:
parent
b69ad0fefc
commit
4ba6ac7332
|
@ -2255,7 +2255,7 @@ void CheckOther::checkAlwaysTrueOrFalseStringCompare()
|
|||
if (!_settings->isEnabled("style") && !_settings->isEnabled("performance"))
|
||||
return;
|
||||
|
||||
const char pattern1[] = "strcmp|stricmp|strcmpi|strcasecmp|wcscmp ( %str% , %str% )";
|
||||
const char pattern1[] = "strncmp|strcmp|stricmp|strcmpi|strcasecmp|wcscmp ( %str% , %str% ";
|
||||
const char pattern2[] = "QString :: compare ( %str% , %str% )";
|
||||
|
||||
const Token *tok = _tokenizer->tokens();
|
||||
|
|
|
@ -3418,6 +3418,16 @@ private:
|
|||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check_preprocess_suppress(
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" if (strncmp(\"hotdog\",\"hotdog\", 6) == 0)"
|
||||
" {"
|
||||
" std::cout << \"Equal\n\""
|
||||
" }"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (warning) Comparison of always identical static strings.\n", errout.str());
|
||||
}
|
||||
|
||||
void check_signOfUnsignedVariable(const char code[]) {
|
||||
|
|
Loading…
Reference in New Issue