Improve the 'suspicious code sizeof sizeof' -message.

As discussed at dev-forum:
https://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=192
This commit is contained in:
Kimmo Varis 2010-11-28 14:20:46 +02:00
parent 3068dbf22e
commit 85735e382f
2 changed files with 4 additions and 2 deletions

View File

@ -2611,7 +2611,9 @@ void CheckOther::sizeofsizeof()
void CheckOther::sizeofsizeofError(const Token *tok)
{
reportError(tok, Severity::warning,
"sizeofsizeof", "Suspicious code 'sizeof sizeof ..', most likely there should only be one sizeof. The current code is equivalent to 'sizeof(size_t)'.");
"sizeofsizeof", "Calling sizeof for 'sizeof'.\n"
"This is suspicious code and most likely there should be just"
"one 'sizeof'. The current code is equivalent to 'sizeof(size_t)'");
}
void CheckOther::sizeofCalculation()

View File

@ -920,7 +920,7 @@ private:
"{\n"
" int i = sizeof sizeof char;\n"
"}\n");
ASSERT_EQUALS("[test.cpp:3]: (warning) Suspicious code 'sizeof sizeof ..', most likely there should only be one sizeof. The current code is equivalent to 'sizeof(size_t)'.\n", errout.str());
ASSERT_EQUALS("[test.cpp:3]: (warning) Calling sizeof for 'sizeof'.\n", errout.str());
}
void sizeofCalculation()