From 37b1f7c296cc8594667d334ab071340ddc5cdf5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 6 Jan 2011 16:27:22 +0100 Subject: [PATCH] memsetZeroBytes: improved error message. ticket: #2421 --- lib/checkother.cpp | 6 +++--- test/testother.cpp | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cf3529de2..6e9101893 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -2819,7 +2819,7 @@ void CheckOther::catchExceptionByValueError(const Token *tok) void CheckOther::memsetZeroBytesError(const Token *tok, const std::string &varname) { - reportError(tok, Severity::warning, - "memsetZeroBytes", "memset() called to fill 0 bytes of \"" + varname + "\"" - ". Second and third arguments might be inverted."); + const std::string summary("memset() called to fill 0 bytes of \'" + varname + "\'"); + const std::string verbose(summary + ". Second and third arguments might be inverted."); + reportError(tok, Severity::warning, "memsetZeroBytes", summary + "\n" + verbose); } diff --git a/test/testother.cpp b/test/testother.cpp index 5284aa522..7992a2849 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1625,7 +1625,7 @@ private: "}\n" ); ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0" - " bytes of \"p\". Second and third arguments might be inverted.\n", errout.str()); + " bytes of \'p\'\n", errout.str()); check("void f() {\n" " memset(p, sizeof(p), 0)\n" @@ -1633,6 +1633,7 @@ private: ); TODO_ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0" " bytes of \"p\". Second and third arguments might be inverted.\n", errout.str()); + ASSERT_EQUALS("", errout.str()); } };