From 7802517a6981af745f0c7e62eda100672e6340cd Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Tue, 12 Jan 2016 23:20:48 +0100 Subject: [PATCH] #7285 wrong var name: memset() called to fill 0 bytes of '&' memset with pointer: remove var name from message. Correct some entries in posix.cfg. --- cfg/posix.cfg | 2 -- lib/checkother.cpp | 2 +- test/testother.cpp | 10 ++++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 3083ac359..4f8554e4d 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -2516,7 +2516,6 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - false @@ -2527,7 +2526,6 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s - false diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 810ec471b..12b21e3c9 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1115,7 +1115,7 @@ void CheckOther::checkMemsetZeroBytes() void CheckOther::memsetZeroBytesError(const Token *tok, const std::string &varname) { - const std::string summary("memset() called to fill 0 bytes of '" + varname + "'."); + const std::string summary("memset() called to fill 0 bytes."); const std::string verbose(summary + " The second and third arguments might be inverted." " The function memset ( void * ptr, int value, size_t num ) sets the" " first num bytes of the block of memory pointed by ptr to the specified value."); diff --git a/test/testother.cpp b/test/testother.cpp index cd7106469..6de730b35 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3265,12 +3265,12 @@ private: check("void f() {\n" " memset(p, 10, 0x0);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0 bytes of 'p'.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0 bytes.\n", errout.str()); check("void f() {\n" " memset(p, sizeof(p), 0);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0 bytes of 'p'.\n", errout.str()); + ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0 bytes.\n", errout.str()); check("void f() {\n" " memset(p, sizeof(p), i);\n" @@ -3286,6 +3286,12 @@ private: "};"); ASSERT_EQUALS("", errout.str()); + // #7285 + check("void f() {\n" + " memset(&tm, sizeof(tm), 0);\n" + "}\n"); + ASSERT_EQUALS("[test.cpp:2]: (warning) memset() called to fill 0 bytes.\n", errout.str()); + } void memsetInvalid2ndParam() {