Code cleanup. Removed CheckLeakAutoVar::doubleDeallocationError since the same checking is already done by CheckOther::checkDoubleFree

This commit is contained in:
Daniel Marjamäki 2012-06-17 07:22:15 +02:00
parent fa2bca1e09
commit 2481b80875
3 changed files with 1 additions and 18 deletions

View File

@ -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());

View File

@ -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
}

View File

@ -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"