From ac357a96f78f917bda1965fb07693d408c5ece71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 31 Dec 2018 18:36:06 +0100 Subject: [PATCH] Fixed #7384 (confuses syntax with variable name / "variable '(' is less than zero") --- lib/checkother.cpp | 8 ++++---- test/testother.cpp | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 0f25c1b8c..3af2200d1 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2058,16 +2058,16 @@ void CheckOther::unsignedLessThanZeroError(const Token *tok, const std::string & if (inconclusive) { reportError(tok, Severity::style, "unsignedLessThanZero", "$symbol:" + varname + "\n" - "Checking if unsigned variable '$symbol' is less than zero. This might be a false warning.\n" - "Checking if unsigned variable '$symbol' is less than zero. An unsigned " + "Checking if unsigned expression '$symbol' is less than zero. This might be a false warning.\n" + "Checking if unsigned expression '$symbol' is less than zero. An unsigned " "variable will never be negative so it is either pointless or an error to check if it is. " "It's not known if the used constant is a template parameter or not and therefore " "this message might be a false warning.", CWE570, true); } else { reportError(tok, Severity::style, "unsignedLessThanZero", "$symbol:" + varname + "\n" - "Checking if unsigned variable '$symbol' is less than zero.\n" - "The unsigned variable '$symbol' will never be negative so it " + "Checking if unsigned expression '$symbol' is less than zero.\n" + "The unsigned expression '$symbol' will never be negative so it " "is either pointless or an error to check if it is.", CWE570, false); } } diff --git a/test/testother.cpp b/test/testother.cpp index a29fa89cd..92cb5340c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4779,7 +4779,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x) {\n" @@ -4795,7 +4795,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x) {\n" @@ -4828,7 +4828,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4844,7 +4844,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4877,7 +4877,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4893,7 +4893,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4926,7 +4926,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4942,7 +4942,7 @@ private: " return true;\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned variable 'x' is less than zero.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Checking if unsigned expression 'x' is less than zero.\n", errout.str()); check( "bool foo(int x, bool y) {\n" @@ -4978,7 +4978,7 @@ private: check(code, nullptr, false, false); ASSERT_EQUALS("", errout.str()); check(code, nullptr, false, true); - ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Checking if unsigned variable 'x' is less than zero. This might be a false warning.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Checking if unsigned expression 'x' is less than zero. This might be a false warning.\n", errout.str()); } } @@ -7238,8 +7238,8 @@ private: " return;\n" " }\n" "}", "test.c"); - ASSERT_EQUALS("[test.c:8]: (style) Checking if unsigned variable 'd.n' is less than zero.\n" - "[test.c:12]: (style) Checking if unsigned variable 'd.n' is less than zero.\n", + ASSERT_EQUALS("[test.c:8]: (style) Checking if unsigned expression 'd.n' is less than zero.\n" + "[test.c:12]: (style) Checking if unsigned expression 'd.n' is less than zero.\n", errout.str()); }