redundantPointerOpError: put pointer name into single quotes in the error message.
This commit is contained in:
parent
3bdbce0bde
commit
2f39ed6f88
|
@ -2525,7 +2525,7 @@ void CheckOther::checkRedundantPointerOp()
|
||||||
void CheckOther::redundantPointerOpError(const Token* tok, const std::string &varname, bool inconclusive)
|
void CheckOther::redundantPointerOpError(const Token* tok, const std::string &varname, bool inconclusive)
|
||||||
{
|
{
|
||||||
reportError(tok, Severity::style, "redundantPointerOp",
|
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()
|
void CheckOther::checkInterlockedDecrement()
|
||||||
|
|
|
@ -5583,12 +5583,12 @@ private:
|
||||||
check("int *f(int *x) {\n"
|
check("int *f(int *x) {\n"
|
||||||
" return &*x;\n"
|
" return &*x;\n"
|
||||||
"}\n", nullptr, false, true);
|
"}\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"
|
check("int *f(int *y) {\n"
|
||||||
" return &(*y);\n"
|
" return &(*y);\n"
|
||||||
"}\n", nullptr, false, true);
|
"}\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
|
// no warning for bitwise AND
|
||||||
check("void f(int *b) {\n"
|
check("void f(int *b) {\n"
|
||||||
|
@ -5618,14 +5618,14 @@ private:
|
||||||
check("void f(Mutex *mut) {\n"
|
check("void f(Mutex *mut) {\n"
|
||||||
" pthread_mutex_lock(&*mut);\n"
|
" pthread_mutex_lock(&*mut);\n"
|
||||||
"}\n", nullptr, false, false);
|
"}\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
|
// make sure we got the AST match for "(" right
|
||||||
check("void f(char *ptr) {\n"
|
check("void f(char *ptr) {\n"
|
||||||
" if (&*ptr == NULL)\n"
|
" if (&*ptr == NULL)\n"
|
||||||
" return;\n"
|
" return;\n"
|
||||||
"}\n", nullptr, false, true);
|
"}\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
|
// no warning for macros
|
||||||
check("#define MUTEX_LOCK(m) pthread_mutex_lock(&(m))\n"
|
check("#define MUTEX_LOCK(m) pthread_mutex_lock(&(m))\n"
|
||||||
|
|
Loading…
Reference in New Issue