From 2481b808754730b77133a9c8193a0c3da0593b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 17 Jun 2012 07:22:15 +0200 Subject: [PATCH] Code cleanup. Removed CheckLeakAutoVar::doubleDeallocationError since the same checking is already done by CheckOther::checkDoubleFree --- lib/checkleakautovar.cpp | 7 +------ lib/checkleakautovar.h | 2 -- test/testleakautovar.cpp | 10 ---------- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/lib/checkleakautovar.cpp b/lib/checkleakautovar.cpp index dbc52ee78..b620374a2 100644 --- a/lib/checkleakautovar.cpp +++ b/lib/checkleakautovar.cpp @@ -83,11 +83,6 @@ void CheckLeakAutoVar::deallocReturnError(const Token *tok, const std::string &v reportError(tok, Severity::error, "newdeallocret", "Returning/using deallocated pointer " + varname); } -void CheckLeakAutoVar::doubleDeallocationError(const Token *tok, const std::string &varname) -{ - reportError(tok, Severity::error, "doubledeallocation", "Double deallocation: " + varname); -} - void CheckLeakAutoVar::configurationInfo(const Token* tok, const std::string &functionName) { if (((!cfgalloc.empty() || !cfgdealloc.empty()) && _settings->isEnabled("style")) || _settings->experimental) { @@ -425,7 +420,7 @@ void CheckLeakAutoVar::functionCall(const Token *tok, VarInfo *varInfo, const st // possible usage possibleUsage[arg->varId()] = tok->str(); } else if (var->second == "dealloc") { - doubleDeallocationError(tok, arg->str()); + // double deallocation is reported by CheckOther::checkDoubleFree } else if (var->second != dealloc) { // mismatching allocation and deallocation mismatchError(tok, arg->str()); diff --git a/lib/checkleakautovar.h b/lib/checkleakautovar.h index 424c13d81..b8e68b1c2 100644 --- a/lib/checkleakautovar.h +++ b/lib/checkleakautovar.h @@ -110,7 +110,6 @@ private: void mismatchError(const Token* tok, const std::string &varname); void deallocUseError(const Token *tok, const std::string &varname); void deallocReturnError(const Token *tok, const std::string &varname); - void doubleDeallocationError(const Token *tok, const std::string &varname); /** message: user configuration is needed to complete analysis */ void configurationInfo(const Token* tok, const std::string &functionName); @@ -120,7 +119,6 @@ private: c.leakError(NULL, "p"); c.mismatchError(NULL, "p"); c.deallocUseError(NULL, "p"); - c.doubleDeallocationError(NULL, "p"); c.configurationInfo(0, "f"); // user configuration is needed to complete analysis } diff --git a/test/testleakautovar.cpp b/test/testleakautovar.cpp index 538f4f7f2..e9e6b0f35 100644 --- a/test/testleakautovar.cpp +++ b/test/testleakautovar.cpp @@ -49,8 +49,6 @@ private: TEST_CASE(deallocuse3); TEST_CASE(deallocuse4); - TEST_CASE(doublefree); - // exit TEST_CASE(exit1); TEST_CASE(exit2); @@ -241,14 +239,6 @@ private: ASSERT_EQUALS("[test.c:3]: (error) Returning/using deallocated pointer p\n", errout.str()); } - void doublefree() { - check("void f(char *p) {\n" - " free(p);\n" - " free(p);\n" - "}"); - ASSERT_EQUALS("[test.c:3]: (error) Double deallocation: p\n", errout.str()); - } - void exit1() { check("void f() {\n" " char *p = malloc(10);\n"