From 2a2adb037ac56af29bd8163b6f5eba045de306a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jan 2009 17:32:33 +0000 Subject: [PATCH] errormessage: Added the new errormessage handling to cppcheck --- src/checkmemoryleak.cpp | 12 ++++-------- src/cppcheck.cpp | 5 ++++- tasks.txt | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/checkmemoryleak.cpp b/src/checkmemoryleak.cpp index d4f0e3569..9ac022355 100644 --- a/src/checkmemoryleak.cpp +++ b/src/checkmemoryleak.cpp @@ -19,6 +19,8 @@ #include "checkmemoryleak.h" +#include "errormessage.h" + #include // free #include @@ -310,17 +312,11 @@ void CheckMemoryLeakClass::MismatchError(const Token *Tok1, const std::listfileLine(tok); - if (alloctype == CheckMemoryLeakClass::FOPEN || alloctype == CheckMemoryLeakClass::POPEN) - errmsg << ": Resource leak: "; + _errorLogger->reportErr(ErrorMessage::resourceLeak(_tokenizer, tok, varname)); else - errmsg << ": Memory leak: "; - - errmsg << varname; - _errorLogger->reportErr(errmsg.str()); + _errorLogger->reportErr(ErrorMessage::memleak(_tokenizer, tok, varname)); } //--------------------------------------------------------------------------- diff --git a/src/cppcheck.cpp b/src/cppcheck.cpp index 34ba4c594..290040eee 100644 --- a/src/cppcheck.cpp +++ b/src/cppcheck.cpp @@ -28,6 +28,8 @@ #include "checkfunctionusage.h" #include "filelister.h" +#include "errormessage.h" + #include #include #include @@ -271,7 +273,8 @@ void CppCheck::checkFile(const std::string &code, const char FileName[]) // Memory leak CheckMemoryLeakClass checkMemoryLeak(&_tokenizer, _settings, this); - checkMemoryLeak.CheckMemoryLeak(); + if ( ErrorMessage::memleak(_settings) ) + checkMemoryLeak.CheckMemoryLeak(); // Check that all class constructors are ok. checkClass.constructors(); diff --git a/tasks.txt b/tasks.txt index 858187915..3fe5bbe91 100644 --- a/tasks.txt +++ b/tasks.txt @@ -12,9 +12,9 @@ The "simple" tasks - etc? * Add unit tests * improved error message handling + * Perhaps the parseArgs function should be moved to the class Settings instead? New checks (bugs) - * sprintf problem with overlapping data * CheckMemoryLeak - Check for more resource leaks Windows API (CreatePen, GetDC, ..)