redundantPointerOpError: put pointer name into single quotes in the error message.

This commit is contained in:
Matthias Krüger 2016-09-16 22:18:24 +02:00
parent 3bdbce0bde
commit 2f39ed6f88
2 changed files with 5 additions and 5 deletions

View File

@ -2525,7 +2525,7 @@ void CheckOther::checkRedundantPointerOp()
void CheckOther::redundantPointerOpError(const Token* tok, const std::string &varname, bool inconclusive)
{
reportError(tok, Severity::style, "redundantPointerOp",
"Redundant pointer operation on " + varname + " - it's already a pointer.", CWE398, inconclusive);
"Redundant pointer operation on '" + varname + "' - it's already a pointer.", CWE398, inconclusive);
}
void CheckOther::checkInterlockedDecrement()

View File

@ -5583,12 +5583,12 @@ private:
check("int *f(int *x) {\n"
" return &*x;\n"
"}\n", nullptr, false, true);
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on x - it's already a pointer.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'x' - it's already a pointer.\n", errout.str());
check("int *f(int *y) {\n"
" return &(*y);\n"
"}\n", nullptr, false, true);
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on y - it's already a pointer.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'y' - it's already a pointer.\n", errout.str());
// no warning for bitwise AND
check("void f(int *b) {\n"
@ -5618,14 +5618,14 @@ private:
check("void f(Mutex *mut) {\n"
" pthread_mutex_lock(&*mut);\n"
"}\n", nullptr, false, false);
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on mut - it's already a pointer.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'mut' - it's already a pointer.\n", errout.str());
// make sure we got the AST match for "(" right
check("void f(char *ptr) {\n"
" if (&*ptr == NULL)\n"
" return;\n"
"}\n", nullptr, false, true);
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on ptr - it's already a pointer.\n", errout.str());
ASSERT_EQUALS("[test.cpp:2]: (style) Redundant pointer operation on 'ptr' - it's already a pointer.\n", errout.str());
// no warning for macros
check("#define MUTEX_LOCK(m) pthread_mutex_lock(&(m))\n"