diff --git a/lib/checkcondition.cpp b/lib/checkcondition.cpp index ed3fde735..454ae7a93 100644 --- a/lib/checkcondition.cpp +++ b/lib/checkcondition.cpp @@ -1580,7 +1580,7 @@ void CheckCondition::alwaysTrueFalseError(const Token* tok, const Token* conditi { const bool alwaysTrue = value && (value->intvalue != 0); const std::string expr = tok ? tok->expressionString() : std::string("x"); - const std::string conditionStr = (Token::simpleMatch(condition, "return") ? "Return" : "Condition"); + const std::string conditionStr = (Token::simpleMatch(condition, "return") ? "Return value" : "Condition"); const std::string errmsg = conditionStr + " '" + expr + "' is always " + (alwaysTrue ? "true" : "false"); const ErrorPath errorPath = getErrorPath(tok, value, errmsg); reportError(errorPath, diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 4f98fc821..6bf65a0ab 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -1309,7 +1309,7 @@ private: check("int f(char c) {\n" " return (c <= 'a' && c >= 'z');\n" "}", "test.cpp", false); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return 'c>='z'' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return value 'c>='z'' is always false\n", errout.str()); } void incorrectLogicOperator7() { // opposite expressions @@ -1885,7 +1885,7 @@ private: " return a % 5 > 5;\n" "}"); ASSERT_EQUALS( - "[test.cpp:7]: (style) Return 'a%5>5' is always false\n" + "[test.cpp:7]: (style) Return value 'a%5>5' is always false\n" "[test.cpp:2]: (warning) Comparison of modulo result is predetermined, because it is always less than 5.\n" "[test.cpp:3]: (warning) Comparison of modulo result is predetermined, because it is always less than 5.\n" "[test.cpp:4]: (warning) Comparison of modulo result is predetermined, because it is always less than 5.\n" @@ -3205,7 +3205,7 @@ private: " if(x == 0) { x++; return x == 0; }\n" " return false;\n" "}"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return 'x==0' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return value 'x==0' is always false\n", errout.str()); check("void f() {\n" // #6898 (Token::expressionString) " int x = 0;\n" @@ -3426,7 +3426,7 @@ private: " const int b = 52;\n" " return a+b;\n" "}"); - ASSERT_EQUALS("[test.cpp:4]: (style) Return 'a+b' is always true\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (style) Return value 'a+b' is always true\n", errout.str()); check("int f() {\n" " int a = 50;\n" @@ -3990,7 +3990,7 @@ private: check("bool f(bool a, bool b) {\n" " return a || ! b || ! a;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return '!a' is always true\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return value '!a' is always true\n", errout.str()); // #10148 check("void f(int i) {\n" @@ -4419,7 +4419,7 @@ private: "[test.cpp:4]: (style) Condition 's.empty()' is always true\n" "[test.cpp:5]: (style) Condition 's.empty()' is always true\n" "[test.cpp:6]: (style) Condition '(bool)0' is always false\n" - "[test.cpp:7]: (style) Return 's.empty()' is always true\n", + "[test.cpp:7]: (style) Return value 's.empty()' is always true\n", errout.str()); check("int f(bool b) {\n" @@ -4430,8 +4430,8 @@ private: " if (b) return static_cast(1);\n" " return (int)0;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:6]: (style) Return 'static_cast(1)' is always true\n" - "[test.cpp:7]: (style) Return '(int)0' is always false\n", + ASSERT_EQUALS("[test.cpp:6]: (style) Return value 'static_cast(1)' is always true\n" + "[test.cpp:7]: (style) Return value '(int)0' is always false\n", errout.str()); check("int f() { return 3; }\n" @@ -4439,7 +4439,7 @@ private: "int h() { if (f()) {} }\n" "int i() { return f() == 3; }\n"); ASSERT_EQUALS("[test.cpp:3]: (style) Condition 'f()' is always true\n" - "[test.cpp:4]: (style) Return 'f()==3' is always true\n", + "[test.cpp:4]: (style) Return value 'f()==3' is always true\n", errout.str()); check("int f() {\n" @@ -4489,7 +4489,7 @@ private: " return (index++) >= s;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:6]: (style) Return '(index++)>=s' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:6]: (style) Return value '(index++)>=s' is always false\n", errout.str()); check("struct a {\n" " a *b() const;\n" @@ -4818,7 +4818,7 @@ private: check("bool f(const int *p, const int *q) {\n" " return p != NULL && q != NULL && p == NULL;\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (style) Return 'p==NULL' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (style) Return value 'p==NULL' is always false\n", errout.str()); } void alwaysTrueContainer() { @@ -5370,7 +5370,7 @@ private: check("bool f(const std::string &s) {\n" " return s.size()>2U && s[0]=='4' && s[0]=='2';\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return 's[0]=='2'' is always false\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:2]: (style) Return value 's[0]=='2'' is always false\n", errout.str()); } void pointerAdditionResultNotNull() {