From 3fc03179979279d48dbe535701ce77d1168306a5 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Mon, 3 Jan 2011 05:15:20 +0100 Subject: [PATCH] Bug #2390: Enclose the output of a variable name with quotes in "CheckOther::variableScopeError" The variable name output was enclosed by quotation marks in the member function "CheckOther::variableScopeError" and corresponding test functions. Signed-off-by: Markus Elfring --- lib/checkother.cpp | 4 ++-- test/testother.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 53ba5fa11..b1e5785f3 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2657,8 +2657,8 @@ void CheckOther::variableScopeError(const Token *tok, const std::string &varname reportError(tok, Severity::information, "variableScope", - "The scope of the variable " + varname + " can be reduced\n" - "The scope of the variable " + varname + " can be reduced. Warning: It can be unsafe " + "The scope of the variable '" + varname + "' can be reduced\n" + "The scope of the variable '" + varname + "' can be reduced. Warning: It can be unsafe " "to fix this message. Be careful. Especially when there are inner loops. Here is an " "example where cppcheck will write that the scope for 'i' can be reduced:\n" "void f(int x)\n" diff --git a/test/testother.cpp b/test/testother.cpp index 6a7d9c106..5dbe9d95c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -465,7 +465,7 @@ private: " for ( ; i < 10; ++i) ;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str()); varScope("void f(int x)\n" "{\n" @@ -475,7 +475,7 @@ private: " for ( ; i < 10; ++i) ;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable i can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:3]: (information) The scope of the variable 'i' can be reduced\n", errout.str()); } void varScope6() @@ -541,7 +541,7 @@ private: " edgeResistance = (edge+1) / 2.0;\n" " }\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable edgeResistance can be reduced\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (information) The scope of the variable 'edgeResistance' can be reduced\n", errout.str()); } void varScope9()