From b5da0b8ed268da9985bcfa14f64bda1386d3369f Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Wed, 7 Jul 2010 15:42:39 +0300 Subject: [PATCH 01/29] Fixed #1650 (Cppcheck deadlock) http://sourceforge.net/apps/trac/cppcheck/ticket/1650 --- cli/threadexecutor.cpp | 105 +++++++++++++++++++----------------- cli/threadexecutor.h | 8 ++- test/testthreadexecutor.cpp | 3 +- 3 files changed, 65 insertions(+), 51 deletions(-) diff --git a/cli/threadexecutor.cpp b/cli/threadexecutor.cpp index 0c1588b63..c4403b75e 100644 --- a/cli/threadexecutor.cpp +++ b/cli/threadexecutor.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #endif ThreadExecutor::ThreadExecutor(const std::vector &filenames, const Settings &settings, ErrorLogger &errorLogger) @@ -51,12 +52,15 @@ void ThreadExecutor::addFileContent(const std::string &path, const std::string & #if (defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__) -bool ThreadExecutor::handleRead(unsigned int &result) +int ThreadExecutor::handleRead(unsigned int &result) { char type = 0; if (read(_pipe[0], &type, 1) <= 0) { - return false; + if( errno == EAGAIN ) + return 0; + + return -1; } if (type != '1' && type != '2' && type != '3') @@ -104,10 +108,12 @@ bool ThreadExecutor::handleRead(unsigned int &result) iss >> fileResult; result += fileResult; _errorLogger.reportStatus(_fileCount, _filenames.size()); + delete [] buf; + return -1; } delete [] buf; - return true; + return 1; } unsigned int ThreadExecutor::check() @@ -134,65 +140,68 @@ unsigned int ThreadExecutor::check() } unsigned int childCount = 0; - for (unsigned int i = 0; i < _filenames.size(); i++) + unsigned int i = 0; + while( true ) { - // Keep only wanted amount of child processes running at a time. - if (childCount >= _settings._jobs) + // Start a new child + if( i < _filenames.size() && childCount < _settings._jobs ) { - while (handleRead(result)) + pid_t pid = fork(); + if (pid < 0) { + // Error + std::cerr << "Failed to create child process" << std::endl; + exit(EXIT_FAILURE); + } + else if (pid == 0) + { + CppCheck fileChecker(*this); + fileChecker.settings(_settings); + if (_fileContents.size() > 0 && _fileContents.find(_filenames[i]) != _fileContents.end()) + { + // File content was given as a string + fileChecker.addFile(_filenames[i], _fileContents[ _filenames[i] ]); + } + else + { + // Read file from a file + fileChecker.addFile(_filenames[i]); + } + + unsigned int resultOfCheck = fileChecker.check(); + std::ostringstream oss; + oss << resultOfCheck; + writeToPipe('3', oss.str()); + exit(0); + } + + ++childCount; + ++i; + } + else if (childCount > 0) + { + // Wait for child to quit before stating new processes + while(true) + { + int readRes = handleRead(result); + if( readRes == -1 ) + break; + else if( readRes == 0 ) + usleep(5000); // 5 ms } int stat = 0; waitpid(0, &stat, 0); --childCount; } - - pid_t pid = fork(); - if (pid < 0) + else if(childCount == 0) { - // Error - std::cerr << "Failed to create child process" << std::endl; - exit(EXIT_FAILURE); + // All done + break; } - else if (pid == 0) - { - CppCheck fileChecker(*this); - fileChecker.settings(_settings); - - if (_fileContents.size() > 0 && _fileContents.find(_filenames[i]) != _fileContents.end()) - { - // File content was given as a string - fileChecker.addFile(_filenames[i], _fileContents[ _filenames[i] ]); - } - else - { - // Read file from a file - fileChecker.addFile(_filenames[i]); - } - - unsigned int resultOfCheck = fileChecker.check(); - std::ostringstream oss; - oss << resultOfCheck; - writeToPipe('3', oss.str()); - exit(0); - } - - ++childCount; } - while (childCount > 0) - { - int stat = 0; - waitpid(0, &stat, 0); - --childCount; - } - - while (handleRead(result)) - { - - } return result; } diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index 7a3e5b8fc..a7122e27b 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -58,7 +58,13 @@ private: #if (defined(__GNUC__) || defined(__sun)) && !defined(__MINGW32__) private: - bool handleRead(unsigned int &result); + /** + * Read from the pipe, parse and handle what ever is in there. + *@return -1 in case of error + * 0 if there is nothing in the pipe to be read + * 1 if we did read something + */ + int handleRead(unsigned int &result); void writeToPipe(char type, const std::string &data); int _pipe[2]; std::list _errorList; diff --git a/test/testthreadexecutor.cpp b/test/testthreadexecutor.cpp index b274a99b7..753379203 100644 --- a/test/testthreadexecutor.cpp +++ b/test/testthreadexecutor.cpp @@ -74,8 +74,7 @@ private: void run() { - // This is commented out, because it causes a deadlock - // TEST_CASE(deadlock_with_many_errors); + TEST_CASE(deadlock_with_many_errors); TEST_CASE(no_errors_more_files); TEST_CASE(no_errors_less_files); TEST_CASE(no_errors_equal_amount_files); From 49626e427e0a3f839df58f2ef85fe0ab0e2383c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 7 Jul 2010 20:28:15 +0200 Subject: [PATCH 02/29] Realloc: changed the error message. I think it's better to mention realloc in the message. --- lib/checkmemoryleak.cpp | 2 +- test/testmemleak.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 75392c8d7..bc4650e4f 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -340,7 +340,7 @@ void CheckMemoryLeak::memleakError(const Token *tok, const std::string &varname) void CheckMemoryLeak::memleakUponReallocFailureError(const Token *tok, const std::string &varname) { - reportErr(tok, Severity::error, "memleakOnRealloc", "Memory leak: \"" + varname + "\" nulled but not freed upon failure"); + reportErr(tok, Severity::error, "memleakOnRealloc", "Common realloc mistake: \"" + varname + "\" nulled but not freed upon failure"); } void CheckMemoryLeak::resourceLeakError(const Token *tok, const std::string &varname) diff --git a/test/testmemleak.cpp b/test/testmemleak.cpp index 4c603f887..e65788036 100644 --- a/test/testmemleak.cpp +++ b/test/testmemleak.cpp @@ -1089,7 +1089,7 @@ private: " ;\n" " free(buf);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:6]: (error) Memory leak: \"buf\" nulled but not freed upon failure\n", errout.str()); + ASSERT_EQUALS("[test.cpp:6]: (error) Common realloc mistake: \"buf\" nulled but not freed upon failure\n", errout.str()); } void if11() @@ -1178,7 +1178,7 @@ private: "\n" " return a;\n" "}\n", true); - ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: \"a\" nulled but not freed upon failure\n", errout.str()); + ASSERT_EQUALS("[test.cpp:9]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n", errout.str()); } @@ -1199,7 +1199,7 @@ private: "\n" " return a;\n" "}\n", true); - ASSERT_EQUALS("[test.cpp:9]: (error) Memory leak: \"a\" nulled but not freed upon failure\n" + ASSERT_EQUALS("[test.cpp:9]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n" "[test.cpp:11]: (error) Memory leak: a\n", errout.str()); } @@ -1932,7 +1932,7 @@ private: " char *a = (char *)malloc(10);\n" " a = realloc(a, 100);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: \"a\" nulled but not freed upon failure\n" + ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n" "[test.cpp:5]: (error) Memory leak: a\n", errout.str()); } @@ -1945,7 +1945,7 @@ private: " free(a);\n" "}\n"); - ASSERT_EQUALS("[test.cpp:4]: (error) Memory leak: \"a\" nulled but not freed upon failure\n", errout.str()); + ASSERT_EQUALS("[test.cpp:4]: (error) Common realloc mistake: \"a\" nulled but not freed upon failure\n", errout.str()); } void realloc3() From 2d6dfa57e12f9000f30f83e9d85007b1e756e00a Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 8 Jul 2010 07:59:47 +0200 Subject: [PATCH 03/29] Variable usage: Better aliasing support (Ticket #1729) --- lib/checkother.cpp | 48 +++++++++++-------- test/testunusedvar.cpp | 104 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 133 insertions(+), 19 deletions(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ce62a987c..cf448b273 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -565,7 +565,7 @@ public: void use(unsigned int varid); void modified(unsigned int varid); VariableUsage *find(unsigned int varid); - void alias(unsigned int varid1, unsigned int varid2); + void alias(unsigned int varid1, unsigned int varid2, bool replace); void erase(unsigned int varid) { _varUsage.erase(varid); @@ -578,35 +578,43 @@ private: VariableMap _varUsage; }; -void Variables::alias(unsigned int varid1, unsigned int varid2) +/** + * Alias the 2 given variables. Either replace the existing aliases if + * they exist or merge them. You would replace an existing alias when this + * assignment is in the same scope as the previous assignment. You might + * merge the aliases when this assignment is in a different scope from the + * previous assignment depending on the relationship of the 2 scopes. + */ +void Variables::alias(unsigned int varid1, unsigned int varid2, bool replace) { + VariableUsage *var1 = find(varid1); + VariableUsage *var2 = find(varid2); + // alias to self if (varid1 == varid2) { - VariableUsage *var = find(varid1); - if (var) - var->use(); + if (var1) + var1->use(); return; } std::set::iterator i; - VariableUsage *var1 = find(varid1); - - // remove var1 from all aliases - for (i = var1->_aliases.begin(); i != var1->_aliases.end(); ++i) + if (replace) { - VariableUsage *temp = find(*i); + // remove var1 from all aliases + for (i = var1->_aliases.begin(); i != var1->_aliases.end(); ++i) + { + VariableUsage *temp = find(*i); - if (temp) - temp->_aliases.erase(var1->_name->varId()); + if (temp) + temp->_aliases.erase(var1->_name->varId()); + } + + // remove all aliases from var1 + var1->_aliases.clear(); } - // remove all aliases from var1 - var1->_aliases.clear(); - - VariableUsage *var2 = find(varid2); - // var1 gets all var2s aliases for (i = var2->_aliases.begin(); i != var2->_aliases.end(); ++i) { @@ -925,13 +933,15 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference var2->_type == Variables::array || var2->_type == Variables::pointer) { - variables.alias(varid1, varid2); + bool replace = true; + + variables.alias(varid1, varid2, replace); } } } else if (var1->_type == Variables::reference) { - variables.alias(varid1, varid2); + variables.alias(varid1, varid2, true); } else { diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 0fa00602f..6d4bf252f 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -1796,6 +1796,56 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " if (a()) {\n" + " buf[0] = 1;\n" + " srcdata = buf;\n" + " srcdata = vdata;\n" + " }\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'buf' is assigned a value that is never used\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " if (a()) {\n" + " buf[0] = 1;\n" + " srcdata = buf;\n" + " }\n" + " srcdata = vdata;\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'buf' is assigned a value that is never used\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " if (a()) {\n" + " srcdata = buf;\n" + " }\n" + " srcdata = vdata;\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Unused variable: buf\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " if (a()) {\n" + " srcdata = vdata;\n" + " }\n" + " srcdata = buf;\n" + " b(srcdata);\n" + "}"); + ASSERT_EQUALS(std::string(""), errout.str()); + functionVariableUsage("void foo()\n" "{\n" " char buf[8];\n" @@ -1810,6 +1860,60 @@ private: " b(srcdata);\n" "}"); ASSERT_EQUALS("", errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " char vdata[8];\n" + " if (a()) {\n" + " buf[0] = 1;\n" + " srcdata = buf;\n" + " srcdata = vdata;\n" + " }\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'buf' is assigned a value that is never used\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " char vdata[8];\n" + " if (a()) {\n" + " buf[0] = 1;\n" + " srcdata = buf;\n" + " }\n" + " srcdata = vdata;\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Variable 'buf' is assigned a value that is never used\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " char vdata[8];\n" + " if (a()) {\n" + " srcdata = buf;\n" + " }\n" + " srcdata = vdata;\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:3]: (style) Unused variable: buf\n"), errout.str()); + + functionVariableUsage("void foo()\n" + "{\n" + " char buf[8];\n" + " char *srcdata;\n" + " char vdata[8];\n" + " if (a()) {\n" + " srcdata = vdata;\n" + " }\n" + " srcdata = buf;\n" + " b(srcdata);\n" + "}"); + TODO_ASSERT_EQUALS(std::string("[test.cpp:5]: (style) Unused variable: vdata\n"), errout.str()); } void localvaralias7() // ticket 1732 From 566b4b4bebff4a4d9e29100fe22e69adef491b0c Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 8 Jul 2010 08:42:34 +0200 Subject: [PATCH 04/29] Variable usage: fixed false positive reported in #1729 --- lib/checkother.cpp | 13 +++++++++++++ test/testunusedvar.cpp | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cf448b273..e6667430c 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -903,6 +903,12 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference next = start + 5 + offset; } + // check for var ? ... + else if (Token::Match(tok->tokAt(start), "%var% ?")) + { + next = start; + } + // no cast else { @@ -937,6 +943,13 @@ static int doAssignment(Variables &variables, const Token *tok, bool dereference variables.alias(varid1, varid2, replace); } + else if (tok->tokAt(next + 1)->str() == "?") + { + if (var2->_type == Variables::reference) + variables.readAliases(varid2); + else + variables.read(varid2); + } } } else if (var1->_type == Variables::reference) diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 6d4bf252f..da4a1fc4b 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -70,6 +70,7 @@ private: TEST_CASE(localvar22); // ticket #1811 TEST_CASE(localvar23); // ticket #1808 TEST_CASE(localvar24); // ticket #1803 + TEST_CASE(localvar25); // ticket #1729 TEST_CASE(localvaralias1); TEST_CASE(localvaralias2); // ticket #1637 TEST_CASE(localvaralias3); // ticket #1639 @@ -1232,6 +1233,18 @@ private: ASSERT_EQUALS("", errout.str()); } + void localvar25() // ticket #1729 + { + functionVariableUsage("int main() {\n" + " int ppos = 1;\n" + " int pneg = 0;\n" + " const char*edge = ppos? \" +\" : pneg ? \" -\" : \"\";\n" + " printf(\"This should be a '+' -> %s\n\", edge);\n" + " return 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void localvaralias1() { functionVariableUsage("void foo()\n" From ee2f785529e8b6d0bd589a683fa507d85bb36f0f Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 8 Jul 2010 10:50:46 +0300 Subject: [PATCH 05/29] GUI: Remove custom lrelease target. Remove the custom lrelease target since it fails to work in Fedora 13. In Fedora 13 there is no 'lrelease' binary but 'lrelease-qt4'. --- gui/gui.pro | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gui/gui.pro b/gui/gui.pro index 678ff009b..0ef54b270 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -82,7 +82,3 @@ win32 { LIBS += -lshlwapi -lhtmlhelp } -# run lrelease before build -lrelease.commands = lrelease gui.pro -QMAKE_EXTRA_TARGETS += lrelease -PRE_TARGETDEPS += lrelease From 11a72461f3f5ea962d226454249ef6dfe1d886a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jul 2010 11:16:49 +0200 Subject: [PATCH 06/29] Fixed #1835 (false positive: uninitialized variable when using ?) --- lib/executionpath.cpp | 7 +++++++ test/testother.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index 5c5200e81..a7012aa59 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -183,6 +183,13 @@ static void checkExecutionPaths_(const Token *tok, std::list &c return; } + // ?: => bailout + if (tok->str() == "?") + { + ExecutionPath::bailOut(checks); + return; + } + if (tok->str() == "switch") { const Token *tok2 = tok->next()->link(); diff --git a/test/testother.cpp b/test/testother.cpp index 416ed7138..d5db3bbf7 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1713,6 +1713,18 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("void foo()\n" + "{\n" + " const char *msgid1, *msgid2;\n" + " int ret = bar(&msgid1);\n" + " if (ret > 0) {\n" + " ret = bar(&msgid2);\n" + " }\n" + " ret = ret <= 0 ? -1 :\n" + " strcmp(msgid1, msgid2) == 0;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // while.. checkUninitVar("int f()\n" "{\n" From 1876cd482ba9af6a849b21ef374b53b515057624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jul 2010 12:06:27 +0200 Subject: [PATCH 07/29] Suppressions: Validate given id --- lib/settings.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/settings.cpp b/lib/settings.cpp index c37ef784b..d098610a7 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -22,6 +22,7 @@ #include #include #include +#include Settings::Settings() { @@ -71,6 +72,26 @@ bool Settings::Suppressions::parseFile(std::istream &istr) void Settings::Suppressions::addSuppression(const std::string &errorId, const std::string &file, unsigned int line) { + // Check that errorId is valid.. + if (errorId.empty()) + { + std::cerr << "Failed to add suppression. No id." << std::endl; + return; + } + for (std::string::size_type pos = 0; pos < errorId.length(); ++pos) + { + if (errorId[pos] < 0 || !std::isalnum(errorId[pos])) + { + std::cerr << "Failed to add suppression. Invalid id \"" << errorId << "\"" << std::endl; + return; + } + if (pos == 0 && std::isdigit(errorId[pos])) + { + std::cerr << "Failed to add suppression. Invalid id \"" << errorId << "\"" << std::endl; + return; + } + } + _suppressions[errorId][file].push_back(line); _suppressions[errorId][file].sort(); } From c34c3ee742f73e5e03906d864730a9909ad04e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jul 2010 13:01:53 +0200 Subject: [PATCH 08/29] Unused functions: Refactoring --- lib/checkunusedfunctions.cpp | 36 +++++++++++++++++------------------- lib/checkunusedfunctions.h | 25 ++++++++++--------------- lib/cppcheck.cpp | 3 +-- lib/errorlogger.h | 11 ----------- test/testunusedfunctions.cpp | 6 ++++-- 5 files changed, 32 insertions(+), 49 deletions(-) diff --git a/lib/checkunusedfunctions.cpp b/lib/checkunusedfunctions.cpp index d00ce218f..6f9c3e6f3 100644 --- a/lib/checkunusedfunctions.cpp +++ b/lib/checkunusedfunctions.cpp @@ -30,21 +30,6 @@ // FUNCTION USAGE - Check for unused functions etc //--------------------------------------------------------------------------- -CheckUnusedFunctions::CheckUnusedFunctions(ErrorLogger *errorLogger) -{ - _errorLogger = errorLogger; -} - -CheckUnusedFunctions::~CheckUnusedFunctions() -{ - -} - -void CheckUnusedFunctions::setErrorLogger(ErrorLogger *errorLogger) -{ - _errorLogger = errorLogger; -} - void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer) { // Function declarations.. @@ -166,7 +151,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer) -void CheckUnusedFunctions::check() +void CheckUnusedFunctions::check(ErrorLogger * const errorLogger) { for (std::map::const_iterator it = _functions.begin(); it != _functions.end(); ++it) { @@ -182,7 +167,7 @@ void CheckUnusedFunctions::check() filename = ""; else filename = func.filename; - _errorLogger->unusedFunction(filename, it->first); + unusedFunctionError(errorLogger, filename, it->first); } else if (! func.usedOtherFile) { @@ -196,7 +181,20 @@ void CheckUnusedFunctions::check() } } -void CheckUnusedFunctions::unusedFunctionError(const Token *tok) +void CheckUnusedFunctions::unusedFunctionError(ErrorLogger * const errorLogger, const std::string &filename, const std::string &funcname) { - reportError(tok, Severity::style, "unusedFunction", "The function 'funcName' is never used"); + std::list locationList; + if (!filename.empty()) + { + ErrorLogger::ErrorMessage::FileLocation fileLoc; + fileLoc.file = filename; + fileLoc.line = 1; + locationList.push_back(fileLoc); + } + + const ErrorLogger::ErrorMessage errmsg(locationList, Severity::stringify(Severity::style), "The function '" + funcname + "' is never used", "unusedFunction"); + if (errorLogger) + errorLogger->reportErr(errmsg); + else + reportError(errmsg); } diff --git a/lib/checkunusedfunctions.h b/lib/checkunusedfunctions.h index a8a39102e..54cfc5e5d 100644 --- a/lib/checkunusedfunctions.h +++ b/lib/checkunusedfunctions.h @@ -32,35 +32,33 @@ class CheckUnusedFunctions: public Check { public: - CheckUnusedFunctions(ErrorLogger *errorLogger = 0); - ~CheckUnusedFunctions(); + /** @brief This constructor is used when registering the CheckUnusedFunctions */ + CheckUnusedFunctions() : Check() + { } - /** - * Errors found by this class are forwarded to the given - * errorlogger. - * @param errorLogger The errorlogger to be used. - */ - void setErrorLogger(ErrorLogger *errorLogger); + /** @brief This constructor is used when running checks. */ + CheckUnusedFunctions(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger) + : Check(tokenizer, settings, errorLogger) + { } // Parse current tokens and determine.. // * Check what functions are used // * What functions are declared void parseTokens(const Tokenizer &tokenizer); - - void check(); + void check(ErrorLogger * const errorLogger); private: void getErrorMessages() { - unusedFunctionError(0); + unusedFunctionError(0, "", "funcName"); } /** * Dummy implementation, just to provide error for --errorlist */ - void unusedFunctionError(const Token *tok); + void unusedFunctionError(ErrorLogger * const errorLogger, const std::string &filename, const std::string &funcname); /** * Dummy implementation, just to provide error for --errorlist @@ -80,9 +78,6 @@ private: return "Check for functions that are never called\n"; } - ErrorLogger *_errorLogger; - - class FunctionUsage { public: diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 38d52e088..192461508 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -624,7 +624,6 @@ unsigned int CppCheck::check() { exitcode = 0; - _checkUnusedFunctions.setErrorLogger(this); std::sort(_filenames.begin(), _filenames.end()); // TODO: Should this be moved out to its own function so all the files can be @@ -728,7 +727,7 @@ unsigned int CppCheck::check() if (_settings._errorsOnly == false) _errorLogger.reportOut("Checking usage of global functions.."); - _checkUnusedFunctions.check(); + _checkUnusedFunctions.check(this); } _errorList.clear(); diff --git a/lib/errorlogger.h b/lib/errorlogger.h index 59602c92c..47f9f6266 100644 --- a/lib/errorlogger.h +++ b/lib/errorlogger.h @@ -162,17 +162,6 @@ public: return true; } - void unusedFunction(const std::string &filename, const std::string &funcname) - { - std::list loc; - ErrorLogger::ErrorMessage::FileLocation fileLoc; - fileLoc.file = filename; - fileLoc.line = 1; - loc.push_back(fileLoc); - reportErr(ErrorLogger::ErrorMessage(loc, "style", "The function '" + funcname + "' is never used", "unusedFunction")); - } - - static bool mismatchAllocDealloc() { return true; diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index 8db48f17f..0c709d6c4 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -58,9 +58,11 @@ private: errout.str(""); // Check for unused functions.. - CheckUnusedFunctions checkUnusedFunctions(this); + Settings settings; + settings._checkCodingStyle = true; + CheckUnusedFunctions checkUnusedFunctions(&tokenizer, &settings, this); checkUnusedFunctions.parseTokens(tokenizer); - checkUnusedFunctions.check(); + checkUnusedFunctions.check(this); } void incondition() From b5d81d0a1983901409b687838cf95a2e79aba060 Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Thu, 8 Jul 2010 17:51:28 +0300 Subject: [PATCH 09/29] Update man page --- man/cppcheck.1.xml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/man/cppcheck.1.xml b/man/cppcheck.1.xml index 724b0da1f..4dec5ec96 100644 --- a/man/cppcheck.1.xml +++ b/man/cppcheck.1.xml @@ -97,25 +97,26 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ &dhpackage; - Simple syntax checking of C/C++. + Tool for static C/C++ code analysis &dhpackage; - + + + - - + @@ -125,10 +126,13 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ DESCRIPTION - Tool for static C/C++ code analysis - intended to complement the checking of the compiler. - Checks for: memory leaks, mismatching allocation-deallocation, - buffer overrun, and many more. + Cppcheck is a command-line tool that tries to detect bugs that your C/C++ + compiler doesn't see. It is versatile, and can check non-standard code + including various compiler extensions, inline assembly code, etc. + Its internal preprocessor can handle includes, macros, and several + preprocessor commands. While Cppcheck is highly configurable, + you can start using it just by giving it a path to the source code. + OPTIONS @@ -262,11 +266,12 @@ files, this is not needed. - Suppress warnings listed in the file. Filename and line are optional. The format of the single line in file is: [error id]:[filename]:[line] + Suppress warnings listed in the file. Filename and line are optional. The format of the single line in file is: [error id]:[filename]:[line]. + You can use --template or --xml to see the error id. - + Format the error messages. E.g. '{file}:{line},{severity},{id},{message}' or '{file}({line}):({severity}) {message}'. Pre-defined templates: gcc, vs @@ -300,7 +305,7 @@ files, this is not needed. AUTHOR - The program was written by Bill Egert, Daniel Marjamäki, Gianluca Scacco, Hoang Tuan Su, Kimmo Varis, Leandro Penz, Nicolas Le Cam, Reijo Tomperi, Slava Semushin and Vesa Pikki + The program was written by Bill Egert, Daniel Marjamäki, Gianluca Scacco, Hoang Tuan Su, Kimmo Varis, Leandro Penz, Martin Ettl, Nguyen Duong Tuan, Nicolas Le Cam, Reijo Tomperi, Robert Reif, Slava Semushin, Vesa Pikki and Zachary Blair SEE ALSO From a60047227d437972e7e4d0d341c48eed5510d7f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 9 Jul 2010 10:18:35 +0200 Subject: [PATCH 10/29] Settings: added '#include ' --- lib/settings.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/settings.cpp b/lib/settings.cpp index d098610a7..9a98ffaad 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -23,6 +23,7 @@ #include #include #include +#include // std::isdigit, std::isalnum, etc Settings::Settings() { From 2531bb73d775a77227f5a16e67af17f0cd7be699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 9 Jul 2010 10:50:24 +0200 Subject: [PATCH 11/29] Fixed #1834 (False positive: invalid iterator when erase() is used in if-else) --- lib/checkstl.cpp | 4 ++++ test/teststl.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/checkstl.cpp b/lib/checkstl.cpp index a2ac2c479..8c70c952d 100644 --- a/lib/checkstl.cpp +++ b/lib/checkstl.cpp @@ -123,6 +123,10 @@ void CheckStl::iterators() { eraseByValueError(tok2, tok2->strAt(0), tok2->strAt(5)); } + else if (Token::Match(tok2, "return|break ;")) + { + validIterator = true; + } } } } diff --git a/test/teststl.cpp b/test/teststl.cpp index 72a0267c7..9d13fc798 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -53,7 +53,8 @@ private: TEST_CASE(erase3); TEST_CASE(erase4); TEST_CASE(eraseBreak); - TEST_CASE(eraseReturn); + TEST_CASE(eraseReturn1); + TEST_CASE(eraseReturn2); TEST_CASE(eraseGoto); TEST_CASE(eraseAssign); TEST_CASE(eraseErase); @@ -442,10 +443,12 @@ private: ASSERT_EQUALS("", errout.str()); } - void eraseReturn() + void eraseReturn1() { check("void f()\n" "{\n" + " std::vector foo;\n" + " std::vector::iterator it;\n" " for (it = foo.begin(); it != foo.end(); ++it)\n" " {\n" " foo.erase(it);\n" @@ -455,6 +458,27 @@ private: ASSERT_EQUALS("", errout.str()); } + void eraseReturn2() + { + check("void f()\n" + "{\n" + " std::vector foo;\n" + " std::vector::iterator it;\n" + " for (it = foo.begin(); it != foo.end(); ++it)\n" + " {\n" + " if (*it == 1) {\n" + " foo.erase(it);\n" + " return;\n" + " }\n" + " else {\n" + " foo.erase(it);\n" + " return;\n" + " }\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } + void eraseGoto() { check("void f()\n" From abbd557761499ee5a195d5ff3b3216e5bd2f97bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 9 Jul 2010 12:42:08 +0200 Subject: [PATCH 12/29] Fixed #1836 (--suppresions file.txt fails due to wrong line edings) --- lib/settings.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/settings.cpp b/lib/settings.cpp index 9a98ffaad..97d979946 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -45,8 +45,17 @@ Settings::Settings() bool Settings::Suppressions::parseFile(std::istream &istr) { + // Change '\r' to '\n' in the istr + std::string filedata; std::string line; - while (getline(istr, line)) + while (std::getline(istr, line)) + filedata += line + "\n"; + while (filedata.find("\r") != std::string::npos) + filedata[filedata.find("\r")] = '\n'; + + // Parse filedata.. + std::istringstream istr2(filedata); + while (std::getline(istr2, line)) { // Skip empty lines if (line.empty()) From 4b0e3edfa42ef036d19455d4417a5053b29a235a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 9 Jul 2010 13:27:15 +0200 Subject: [PATCH 13/29] Unit Testing: Test that suppressions work --- Makefile | 4 +++ lib/settings.cpp | 16 +++++++----- lib/settings.h | 3 ++- test/testsettings.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 test/testsettings.cpp diff --git a/Makefile b/Makefile index 3242804ca..53e96e9d5 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,7 @@ TESTOBJ = test/testautovariables.o \ test/testpreprocessor.o \ test/testredundantif.o \ test/testrunner.o \ + test/testsettings.o \ test/testsimplifytokens.o \ test/teststl.o \ test/testsuite.o \ @@ -213,6 +214,9 @@ test/testredundantif.o: test/testredundantif.cpp lib/tokenize.h lib/classinfo.h test/testrunner.o: test/testrunner.cpp test/testsuite.h lib/errorlogger.h lib/settings.h $(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testrunner.o test/testrunner.cpp +test/testsettings.o: test/testsettings.cpp lib/settings.h test/testsuite.h lib/errorlogger.h + $(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testsettings.o test/testsettings.cpp + test/testsimplifytokens.o: test/testsimplifytokens.cpp test/testsuite.h lib/errorlogger.h lib/settings.h lib/tokenize.h lib/classinfo.h lib/token.h $(CXX) $(CXXFLAGS) -Ilib -Icli -c -o test/testsimplifytokens.o test/testsimplifytokens.cpp diff --git a/lib/settings.cpp b/lib/settings.cpp index 97d979946..f3a21ba37 100644 --- a/lib/settings.cpp +++ b/lib/settings.cpp @@ -53,6 +53,8 @@ bool Settings::Suppressions::parseFile(std::istream &istr) while (filedata.find("\r") != std::string::npos) filedata[filedata.find("\r")] = '\n'; + bool ret = true; + // Parse filedata.. std::istringstream istr2(filedata); while (std::getline(istr2, line)) @@ -74,36 +76,38 @@ bool Settings::Suppressions::parseFile(std::istream &istr) } // We could perhaps check if the id is valid and return error if it is not - addSuppression(id, file, lineNumber); + ret &= addSuppression(id, file, lineNumber); } - return true; + return ret; } -void Settings::Suppressions::addSuppression(const std::string &errorId, const std::string &file, unsigned int line) +bool Settings::Suppressions::addSuppression(const std::string &errorId, const std::string &file, unsigned int line) { // Check that errorId is valid.. if (errorId.empty()) { std::cerr << "Failed to add suppression. No id." << std::endl; - return; + return false; } for (std::string::size_type pos = 0; pos < errorId.length(); ++pos) { if (errorId[pos] < 0 || !std::isalnum(errorId[pos])) { std::cerr << "Failed to add suppression. Invalid id \"" << errorId << "\"" << std::endl; - return; + return false; } if (pos == 0 && std::isdigit(errorId[pos])) { std::cerr << "Failed to add suppression. Invalid id \"" << errorId << "\"" << std::endl; - return; + return false; } } _suppressions[errorId][file].push_back(line); _suppressions[errorId][file].sort(); + + return true; } bool Settings::Suppressions::isSuppressed(const std::string &errorId, const std::string &file, unsigned int line) diff --git a/lib/settings.h b/lib/settings.h index 4ce21d54a..32baeb2e4 100644 --- a/lib/settings.h +++ b/lib/settings.h @@ -145,8 +145,9 @@ public: * @param errorId the id for the error, e.g. "arrayIndexOutOfBounds" * @param file File name with the path, e.g. "src/main.cpp" * @param line number, e.g. "123" + * @return true on success, false in syntax error is noticed. */ - void addSuppression(const std::string &errorId, const std::string &file = "", unsigned int line = 0); + bool addSuppression(const std::string &errorId, const std::string &file = "", unsigned int line = 0); /** * @brief Returns true if this message should not be shown to the user. diff --git a/test/testsettings.cpp b/test/testsettings.cpp new file mode 100644 index 000000000..7abfde29c --- /dev/null +++ b/test/testsettings.cpp @@ -0,0 +1,57 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2010 Daniel Marjamäki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "settings.h" +#include "testsuite.h" + +#include + +extern std::ostringstream errout; + +class TestSettings : public TestFixture +{ +public: + TestSettings() : TestFixture("TestSettings") + { } + +private: + + void run() + { + TEST_CASE(suppressionsBadId1); + TEST_CASE(suppressionsDosFormat); // Ticket #1836 + } + + void suppressionsBadId1() + { + Settings::Suppressions suppressions; + std::istringstream s("123"); + ASSERT_EQUALS(false, suppressions.parseFile(s)); + } + + void suppressionsDosFormat() + { + Settings::Suppressions suppressions; + std::istringstream s("abc\r\ndef\r\n"); + ASSERT_EQUALS(true, suppressions.parseFile(s)); + ASSERT_EQUALS(true, suppressions.isSuppressed("abc", "test.cpp", 1)); + ASSERT_EQUALS(true, suppressions.isSuppressed("def", "test.cpp", 1)); + } +}; + +REGISTER_TEST(TestSettings) From 2e03e60218d8d1136e8c033ddee87fc801d8a848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Jul 2010 08:12:23 +0200 Subject: [PATCH 14/29] Manual: Better description of -D. As suggested by kwin. Ticket #1212 --- man/manual.docbook | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/man/manual.docbook b/man/manual.docbook index 2c0d8db9c..e1837b5a8 100644 --- a/man/manual.docbook +++ b/man/manual.docbook @@ -3,9 +3,9 @@ "/usr/share/xml/docbook/schema/dtd/4.4/docbookx.dtd"> - Cppcheck 1.43 + Cppcheck 1.44 - 2010-05-08 + 2010-07-10 @@ -165,9 +165,14 @@ Checking path/file2.cpp... But if you want to manually limit the checking you can do so with -D. - For example, if you want to limit the checking so the only - configuration to check should be "DEBUG=1;__cplusplus" then something like - this can be used: + Beware that only the macros, which are given here and the macros + defined in source files and known header files are considered. That + excludes all the macros defined in some system header files, which are by + default not examined by cppcheck. + + The usage: if you, for example, want to limit the checking so the + only configuration to check should be "DEBUG=1;__cplusplus" then something + like this can be used: cppcheck -DDEBUG=1 -D__cplusplus path @@ -220,7 +225,7 @@ Checking path/file2.cpp... severity - one of: error / possible error / style / possible style + either error or style From 94a8eba989e8ad4ffa478685fae48aadecf5db90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Jul 2010 11:29:07 +0200 Subject: [PATCH 15/29] 1.44: updated version information --- cli/cppcheck.rc | 8 ++++---- cli/main.cpp | 2 +- lib/cppcheck.cpp | 2 +- win_installer/productInfo.wxi | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/cppcheck.rc b/cli/cppcheck.rc index 08bb3b0d8..a88c656b8 100644 --- a/cli/cppcheck.rc +++ b/cli/cppcheck.rc @@ -56,8 +56,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,43,0,0 - PRODUCTVERSION 1,43,0,0 + FILEVERSION 1,44,0,0 + PRODUCTVERSION 1,44,0,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -73,12 +73,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "cppcheck Application" - VALUE "FileVersion", "1.43" + VALUE "FileVersion", "1.44" VALUE "InternalName", "cppcheck" VALUE "LegalCopyright", "Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team." VALUE "OriginalFilename", "cppcheck.exe" VALUE "ProductName", "cppcheck Application" - VALUE "ProductVersion", "1.43" + VALUE "ProductVersion", "1.44" END END BLOCK "VarFileInfo" diff --git a/cli/main.cpp b/cli/main.cpp index eae0790ac..2a57f4d5d 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -20,7 +20,7 @@ /** * * @mainpage Cppcheck - * @version 1.43 + * @version 1.44 * * @section overview_sec Overview * Cppcheck is a simple tool for static analysis of C/C++ code. diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 192461508..415beaadd 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -202,7 +202,7 @@ void CppCheck::clearFiles() const char * CppCheck::version() { - return "1.43"; + return "1.44"; } diff --git a/win_installer/productInfo.wxi b/win_installer/productInfo.wxi index 60003a0ee..cba078c3b 100755 --- a/win_installer/productInfo.wxi +++ b/win_installer/productInfo.wxi @@ -1,8 +1,8 @@ - + - + From 72263d64b0e250abc4e0549a96b0c705f5403980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Jul 2010 11:30:03 +0200 Subject: [PATCH 16/29] Changelog: updated for release --- Changelog | 1317 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1317 insertions(+) diff --git a/Changelog b/Changelog index 29f034f53..5e423ae82 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,1320 @@ +2010-07-10 Daniel Marjamäki + + * cli/cppcheck.rc, cli/main.cpp, lib/cppcheck.cpp, + win_installer/productInfo.wxi: 1.44: updated version information + +2010-07-10 Daniel Marjamäki + + * man/manual.docbook: Manual: Better description of -D. As suggested + by kwin. Ticket #1212 + +2010-07-09 Daniel Marjamäki + + * Makefile, lib/settings.cpp, lib/settings.h, test/testsettings.cpp: + Unit Testing: Test that suppressions work + +2010-07-09 Daniel Marjamäki + + * lib/settings.cpp: Fixed #1836 (--suppresions file.txt fails due to + wrong line edings) + +2010-07-09 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #1834 (False positive: + invalid iterator when erase() is used in if-else) + +2010-07-09 Daniel Marjamäki + + * lib/settings.cpp: Settings: added '#include ' + +2010-07-08 Reijo Tomperi + + * man/cppcheck.1.xml: Update man page + +2010-07-08 Daniel Marjamäki + + * lib/checkunusedfunctions.cpp, lib/checkunusedfunctions.h, + lib/cppcheck.cpp, lib/errorlogger.h, test/testunusedfunctions.cpp: + Unused functions: Refactoring + +2010-07-08 Daniel Marjamäki + + * lib/settings.cpp: Suppressions: Validate given id + +2010-07-08 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: Fixed #1835 (false + positive: uninitialized variable when using ?) + +2010-07-08 Kimmo Varis + + * gui/gui.pro: GUI: Remove custom lrelease target. Remove the custom lrelease target since it fails to work in Fedora + 13. In Fedora 13 there is no 'lrelease' binary but 'lrelease-qt4'. + +2010-07-08 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Variable usage: fixed + false positive reported in #1729 + +2010-07-08 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Variable usage: Better + aliasing support (Ticket #1729) + +2010-07-07 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Realloc: changed + the error message. I think it's better to mention realloc in the + message. + +2010-07-07 Reijo Tomperi + + * cli/threadexecutor.cpp, cli/threadexecutor.h, + test/testthreadexecutor.cpp: Fixed #1650 (Cppcheck deadlock) + http://sourceforge.net/apps/trac/cppcheck/ticket/1650 + +2010-07-07 Reijo Tomperi + + * test/testthreadexecutor.cpp: Add more unit tests + +2010-07-07 Kimmo Varis + + * gui/mainwindow.cpp, gui/threadhandler.cpp, gui/threadhandler.h: + Fixed #1831 (GUI: no progress bar when rechecking files) Need to initialize the checking also when rechecking. + +2010-07-07 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1825 (*log(0) + error) + +2010-07-07 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Variable usage: only + warn about variables that have variable id > 0 + +2010-07-07 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1803 (False + positive: unused variable: this) + +2010-07-07 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1729 (False + positive: variable is assigned a value that is never used (pointer + aliasing)) + +2010-07-07 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1829 (### + Internal error in Cppcheck. Please report it.) + +2010-07-06 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1789 (false + positive: memory leak (reallocation in subfunction through + parameter)) + +2010-07-06 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: Fixed #1824 (false + positive: unitialised variable) + +2010-07-06 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1827 (### + Internal error in Cppcheck. Please report it.) + +2010-07-05 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1821 + (simplifyTypedef: better typedef support) + +2010-07-05 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1823 (tokenize && + wrong) + +2010-07-05 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Buffer + Overrun: Fixed false positive when variable is reassigned in called + function + +2010-07-05 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1820 (False + positive: memory leak (auto deallocated class)) + +2010-07-05 Daniel Marjamäki + + * gui/cppcheck_se.ts: GUI: updated swedish translation + +2010-07-05 Daniel Marjamäki + + * gui/cppcheck_se.ts: GUI: updated swedish translation + +2010-07-05 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1817 (False + positive: Resource leak (casting)) + +2010-07-05 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1818 (False + positive: Dangerous usage of strncpy (copying a constant string)) + +2010-07-04 Kimmo Varis + + * gui/mainwindow.cpp, gui/resultsview.cpp, gui/resultsview.h, + gui/threadhandler.cpp, gui/threadresult.cpp, gui/threadresult.h: + GUI: Refactoring progress/finished handling. Progress signal had also item count with it and then the handler + determined that check is ready when max count of progress was done. + Also progressbar was practically reset in every progress signal. + This was simply fragile code. After this patch progress signal has only the current progress + count. Total count of items is given when initializing the checking. + And there is separate function for handling check finishing. This also fixes the bug that progressbar was not hidden after + checking or when interrupting the checking. + +2010-07-04 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, + gui/cppcheck_se.ts: GUI: Fixup TS translation files after they got + messed up earlier. The lupdate got confused of removing "Show security errors" and + there being existing string "Show style errors". lupdate thought the + "Show style errors" was a new version ("similar enough") of "Show + security errors" string instead of new string to translate. Or + actually existing translated string. So many translations got "Show + style errors" translated by earlier translation of "Show security + errors". This commit fixes the mess by manually removing "Show security + errors" references and restoring correct translations of "Show style + errors" from earlier file versions. Good lesson to learn about lupdate behavior. + +2010-07-04 Kimmo Varis + + * gui/gui.cppcheck, gui/mainwindow.cpp, gui/projectfile.cpp, + gui/projectfile.h: GUI: Remove code for automatic deallocated + classes. Project file code still read the list of automatically deallocated + classes from project file. That feature hasn't been supported in few + last releases. + +2010-07-03 Kimmo Varis + + * gui/main.ui: GUI: Change UI file to LF EOLs. In previous commit I accidentally committed the UI file with CRLF + EOLs. + +2010-07-03 Kimmo Varis + + * gui/common.h, gui/main.ui, gui/mainwindow.cpp, gui/mainwindow.h: + GUI: Refactoring toolbar member names to be more consistent. + +2010-07-03 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, + gui/cppcheck_se.ts: GUI: Update translation files. + +2010-07-03 Kimmo Varis + + * gui/common.h, gui/main.ui, gui/mainwindow.cpp, gui/mainwindow.h: + GUI: Add View-menu item for showing/hiding Categories-toolbar. + +2010-07-03 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, + gui/cppcheck_se.ts, gui/main.ui: GUI: Move menuitem to hide/show + main toolbar to own submenu. + +2010-07-03 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, + gui/cppcheck_se.ts, gui/gui.qrc, gui/main.ui: GUI: Add new toolbar + for error/warning categories. This commit adds new toolbar to the GUI for fast and easy switching + of different warning//error categories. The icons are currently just + placeholders until more descriptive icons are created. + +2010-07-03 Kimmo Varis + + * gui/main.ui, gui/mainwindow.cpp: GUI: Rename main toolbar in code. + +2010-07-03 Kimmo Varis + + * gui/common.h, gui/cppcheck_de.ts, gui/cppcheck_en.ts, + gui/cppcheck_fi.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/main.ui, + gui/mainwindow.cpp, gui/mainwindow.h, gui/resultstree.cpp: GUI: + Remove remains of "possible error". + +2010-07-03 Kimmo Varis + + * gui/cppcheck_de.ts, gui/cppcheck_en.ts, gui/cppcheck_fi.ts, + gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, gui/cppcheck_ru.ts, + gui/cppcheck_se.ts, gui/main.ui: GUI: Remove "Show security errors" + action. There was no code using this, just GUI action for it. + +2010-07-03 Kimmo Varis + + * gui/common.h, gui/cppcheck_de.ts, gui/cppcheck_en.ts, + gui/cppcheck_fi.ts, gui/cppcheck_nl.ts, gui/cppcheck_pl.ts, + gui/cppcheck_ru.ts, gui/cppcheck_se.ts, gui/main.ui, + gui/mainwindow.cpp, gui/mainwindow.h, gui/resultstree.cpp: GUI: + Remove remains of "all style". Earlier "all style" was just removed as menu item but all the code + related was left in place. This commit actually removes the now + unneeded code. + +2010-07-02 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1821 + (simplifyTypedef: better typedef support) + +2010-06-30 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1790 + (mismatching allocation/deallocation false positive) + +2010-06-30 Zachary Blair + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #157 (Forgetting to put a break in a switch statement) + +2010-06-30 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1815 (False + positive: uninitialized variable when using ? operator) + +2010-06-30 Robert Reif + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + Fixed #1816 (Tokenizer: remove restrict keyword) + +2010-06-29 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: Class checking: Fixed FP + for static arrays (not initialized in constructor) + +2010-06-29 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1808 (false + positive: uninitialized variable with multiple assignment) + +2010-06-28 Kimmo Varis + + * win_installer/cppcheck.wxs: MSI Installer: Fix description text. + +2010-06-28 Kimmo Varis + + * : commit 914891f247dee27826b9ad0ca65c3ece364a8f8f Author: Kimmo + Varis Date: Mon Jun 28 20:47:00 2010 +0300 + +2010-06-28 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: --author=Robert + Reif Fixed #1814 (false positive: Variable hides typedef with same name) + +2010-06-28 Kimmo Varis + + * win_installer/modpath.iss, win_installer/readme_InnoSetup.txt: + Remove remaining Innosetup installer files. Innosetup installer was removed earlier but some files related to it + were not removed. + +2010-06-26 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1809 (false + positive: uninitialized variable with nested if) + +2010-06-26 Robert Reif + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1811 (false + positive: Uninitialized variable) + +2010-06-25 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1808 (false + positive: uninitialized variable with multiple assignment) + +2010-06-25 Robert Reif + + * test/testclass.cpp: Unit Testing: Added TODO test case for + uninitialized member variable in operator=. Ticket: #1813 + +2010-06-25 Robert Reif + + * lib/tokenize.cpp, test/testunusedvar.cpp: Fixed #1813 (false + negative: Member variable not assigned a value in operator=) + +2010-06-24 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1495 (False -s + positive: Member variable not assigned a value in operator=) + +2010-06-24 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1812 (false + negative: functionVariableUsage doesn't support static variables) + +2010-06-24 firewave + + * lib/checkclass.cpp: Avoid Visual Studio warnings about constant + expressions + +2010-06-23 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1732 (False + positive: Variable not assigned a value (pointer to pointer)) + +2010-06-22 Robert Reif + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1810 (False + positive: Variable 'separator' is assigned a value that is never + used) + +2010-06-22 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1807 (false + positive: Variable is not assigned a value (casting function + parameters)) + +2010-06-21 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1800 (false + positive: memory leak when ptr used as map key) + +2010-06-21 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1799 (false + positive: Variable is assigned a value that is never used) + +2010-06-20 Daniel Marjamäki + + * lib/tokenize.cpp: Refactoring: Removed redundant checks + +2010-06-20 Daniel Marjamäki + + * lib/checkother.cpp: Refactoring: Reduced copy/pasted code + +2010-06-20 Daniel Marjamäki + + * lib/preprocessor.cpp: Preprocessor: Reduce copy/pasted code + +2010-06-20 Martin Ettl + + * test/testdangerousfunctions.cpp: added testcases for testing + dangerous functions: mktemp + +2010-06-19 Nicolás Alvarez + + * lib/preprocessor.cpp: Change size-t to std::string::size_type. + +2010-06-19 Nicolás Alvarez + + * lib/preprocessor.cpp: Fix build error on 64-bit systems. + +2010-06-11 Nicolás Alvarez + + * lib/checkother.cpp, test/testother.cpp: Fix typos in sizeofsizeof + error message. + +2010-06-19 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1795 (false + positive: nullpointer dereference (needs to improve + Tokenizer::simplifyKnownVariables)) + +2010-06-19 Daniel Marjamäki + + * lib/checkother.cpp, lib/tokenize.cpp, test/testother.cpp, + test/testtokenize.cpp: Fixed #1633 (tokenizer: + simplifyKnownVariable: improved handling of arithmetic) + +2010-06-19 Daniel Marjamäki + + * lib/preprocessor.cpp, test/testpreprocessor.cpp: Fixed #1802 + (Preprocessor: macros are expanded wrong) + +2010-06-19 Daniel Marjamäki + + * lib/preprocessor.cpp: Preprocessor: Refactoring. Broke out code + that parses out the parameters from code. + +2010-06-19 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp: Borland C++: Fixed compiler errors. + When using 'a?b:c', Borland requires that b and c are the same type + +2010-06-19 Daniel Marjamäki + + * cppcheck.cbproj, testrunner.cbproj: Borland C++: Updated project + files + +2010-06-18 Robert Reif + + * test/testunusedvar.cpp: Refactoring testunusedvariables. This + fixes #1804. + +2010-06-18 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1801 + (simplifyTypedef: duplicate typedefs not handled properly) + +2010-06-18 Reijo Tomperi + + * Makefile, test/testthreadexecutor.cpp, tools/dmake.cpp: Added test + case deadlock_with_many_errors() for ticket #1650 + http://sourceforge.net/apps/trac/cppcheck/ticket/1650 The test case + is currently commented out, because it would cause tests to hang + also. + +2010-06-17 firewave + + * cli/cppcheck.vcproj, cli/cppcheck.vcxproj, + cli/cppcheck.vcxproj.filters, lib/lib.vcproj, lib/lib.vcxproj, + lib/lib.vcxproj.filters, test/test.vcproj, test/test.vcxproj, + test/test.vcxproj.filters: Removed obsolete checkheaders from Visual + Studio projects + +2010-06-17 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1801 + (Segmentation fault while scanning Qt's qcups.cpp) + +2010-06-16 Leandro Lisboa Penz + + * test/testmemleak.cpp: Ticket #1789 is not really fixed; added + TODO. + +2010-06-16 Leandro Lisboa Penz + + * test/testmemleak.cpp: Improved test of pointer argument realloc. + +2010-06-16 Leandro Lisboa Penz + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + test/testmemleak.cpp: Fixed #1789 (false positive: memory leak + (reallocation in subfunction through parameter)) Detecting reallocations in the other function. + +2010-06-16 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #853 (False + positive: memory leak for member variable with unknown function) + +2010-06-16 Robert Reif + + * lib/token.cpp, lib/tokenize.cpp, test/testunusedvar.cpp: variable + usage: fix false positives when __attribute__ is used. Ticket: #1792 + +2010-06-16 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: simplify the alias + handling in the checking of variable usage. Ticket: #1729 + +2010-06-16 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1798 + (structure templates) + +2010-06-15 Zachary Blair + + * lib/checkother.cpp: Applied review suggestions for Ticket #920 + +2010-06-15 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #1545 (new check: usage + of iterator pointing to invalid memory after reserve) + +2010-06-15 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #887 (Tokenizer: + Simplify variable value after loop) + +2010-06-15 Daniel Marjamäki + + * Makefile, lib/checkheaders.cpp, lib/checkheaders.h, lib/lib.pri: + removed the deprecated checkheaders + +2010-06-14 Zachary Blair + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #920 (new style check: find empty catch blocks) + +2010-06-14 Reijo Tomperi + + * Makefile, cli/threadexecutor.cpp, cli/threadexecutor.h, + cppcheck.cbp, test/testthreadexecutor.cpp: Add + testthreadexecutor.cpp + +2010-06-14 Robert Reif + + * lib/checkother.cpp, lib/token.cpp, lib/token.h, lib/tokenize.cpp, + test/testunusedvar.cpp: Fixed #1792 (false positive: Variable 'test' + is assigned a value that is never used) + +2010-06-14 Daniel Marjamäki + + * lib/checkother.cpp, lib/tokenize.cpp, test/testother.cpp, + test/testtokenize.cpp: Fixed #1776 (False Negative: Unitialized + array) + +2010-06-14 Daniel Marjamäki + + * lib/check.h, lib/checkbufferoverrun.cpp, lib/checkother.h, + lib/executionpath.h, lib/token.h: doxygen: fixed error messages + given by doxygen + +2010-06-13 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: more + specific bailouts to reduce false negatives + +2010-06-13 Daniel Marjamäki + + * test/testmemleak.cpp: Added testcase for #1557 (false positive: + memory leak) + +2010-06-13 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1783 (false + positive: uninitalized variable in constructor/operator=, when + calling overloaded functions) + +2010-06-13 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1718 (Tokenizer + add close braces to for loop at wrong place when if-else presents + inside) + +2010-06-13 Robert Reif + + * lib/checkbufferoverrun.cpp, lib/checkclass.cpp, lib/tokenize.cpp, + test/testbufferoverrun.cpp: Fixed #1787 (false negative: out of + bounds in derived class) + +2010-06-12 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1510 (false + positive '(possible error) Memory leak' when 'a = b = new ...; + delete a' (but not b)) + +2010-06-12 Daniel Marjamäki + + * test/testmemleak.cpp: reverted 'added a todo testcase for ticket + #1788' + +2010-06-12 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1788 + (Tokenizer: template destructor is lost) + +2010-06-11 Martin Ettl + + * test/testmemleak.cpp: added a few testcases for checking memory + leaks in classes + +2010-06-11 Martin Ettl + + * test/testmemleak.cpp: added a todo testcase for ticket #1788 + +2010-06-10 Martin Ettl + + * test/testmemleak.cpp: added todo-testcase for ticket #1401 + +2010-06-10 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1784 (false + positive: Variable is not assigned a value) + +2010-06-10 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1782 + ((error) ### Internal error in Cppcheck. Please report it.) + +2010-06-09 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1781 (false + positive: uninitialized variable when using asm statement in macro) + +2010-06-09 Martin Ettl + + * test/testother.cpp: added a todo testcase for ticket 1778 + +2010-06-08 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Variable usage: read + variable when using syntax '..=*(p);' + +2010-06-07 Martin Ettl + + * AUTHORS: added Martin Ettl to authors list + +2010-06-06 Robert Reif + + * test/testunusedvar.cpp: Variable usage: Added TODO testcases for + handling pointer alias. Ticket: #1729 + +2010-06-06 Martin Ettl + + * test/testbufferoverrun.cpp: added TODO_TESTCASE for ticket 1734: + Array index out of bounds + +2010-06-06 Martin Ettl + + * test/testclass.cpp: added a TODO testcase for ticket 1724 + +2010-06-06 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1726 (False + negative: null pointer dereference in switch block) + +2010-06-06 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: + skipping function call inside allocation + +2010-06-06 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: Added + allocation function 'g_strdup_printf' + +2010-06-06 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1722 (Member + variable initialized in call to base class constructor) + +2010-06-05 Martin Ettl + + * lib/checkclass.cpp, test/testclass.cpp: applied patch from + php-coder from ticket 1724; removed TODO_TESTCASES; + +2010-06-05 Daniel Marjamäki + + * man/cppcheck.1.xml: man: updated the cppcheck.1.xml file. + +2010-06-05 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: Code coverage: Removed unused code + +2010-06-05 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: Fixed #1725 (segfault + in ExecutionPath::bailOutVar (probably caused by #1721 fix)) + +2010-06-04 Leandro Lisboa Penz + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + test/testmemleak.cpp: Fixed #73 (memory leaks not found when calling + a function that returns allocated memory through a parameter) + +2010-06-03 Zachary Blair + + * AUTHORS: Added Zachary Blair to the AUTHORS file + +2010-06-03 Zachary Blair + + * lib/checkbufferoverrun.cpp: Applied review suggestions for Ticket + #568 + +2010-06-04 Guillaume Miossec + + * gui/cppcheck_fr.ts: Added french translation + +2010-06-03 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: Fixed #1721 (False + negative: uninitialized variable in switch block) + +2010-06-03 Martin Ettl + + * test/testclass.cpp: run astyle + +2010-06-03 Martin Ettl + + * test/testclass.cpp: removed a wrong const declaration + +2010-06-03 Martin Ettl + + * test/testclass.cpp: added a testcase and todo testcases for ticket + #1724 + +2010-06-03 Robert Reif + + * lib/checkother.cpp, lib/tokenize.cpp, test/testtokenize.cpp, + test/testunusedvar.cpp: Fixed #1723 (Variable assigned value which + is never used but is thrown) + +2010-06-02 Daniel Marjamäki + + * lib/cppcheck.cpp: updated --help output. The --enable is used to + enable additional checks. + +2010-06-02 Daniel Marjamäki + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1720 + (segmentation fault of cppcheck) + +2010-06-02 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: astyle formatting + +2010-06-02 Daniel Marjamäki + + * lib/checkother.cpp: CheckOther::nullConstantDereference: Fixed + cppcheck warning message - tok may become null + +2010-06-02 Daniel Marjamäki + + * lib/checkother.cpp: Refactoring of + CheckOther::nullConstantDereference + +2010-06-01 Zachary Blair + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Fixed #568 (string functions with + command line arguments may overflow buffer) + +2010-06-01 Nicolás Alvarez + + * generate_coverage_report: coverage report script: Extract only + relevant data from the .info file. Only files in the current directory are kept. This gets rid of + standard C++ library headers from the coverage report. + +2010-06-01 Nicolás Alvarez + + * generate_coverage_report: coverage report script: Quit immediately + on errors, but don't consider missing coverage_report dir when + deleting it as an error + +2010-06-01 Daniel Marjamäki + + * test/testunusedvar.cpp: Added unit test for ticket #1720 + +2010-05-31 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1719 (False + negative: memory leak (fgets in condition)) + +2010-05-30 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: Fixed + bug in CheckMemoryLeak::functionReturnType + +2010-05-30 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1717 (False + positive: Resource leak with while) + +2010-05-30 Daniel Marjamäki + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + Tokenizer: simplify loops that continue while errno is EINTR + +2010-05-30 firewave + + * lib/checkother.h: Fixed Visual Studio 2010 warning + +2010-05-30 firewave + + * .gitignore: Added *.opensdf to ignore list + +2010-05-30 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Uninitialized variables: + fixed false negative when using uninitialized variable inside malloc + call + +2010-05-30 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Uninitialized variables: + better handling when uninitialized variables are used in function + calls + +2010-05-30 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: ExecutionPath: Better + handling of 'FOREACH (..) {}' + +2010-05-30 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: ExecutionPath: better + handling of 'FOREACH(..){..}' + +2010-05-30 Daniel Marjamäki + + * lib/checkother.cpp: Refactoring uninitialized variables (checking + variable declarations) + +2010-05-30 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Uninitialized variables: + better handling of struct variables + +2010-05-29 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1716 (Wrong + reporting of leak with close() in a while loop condition) + +2010-05-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: small + fixes. add checking of 'g_fopen'. don't let 'fclose' calls be + interpreted as 'callfunc' + +2010-05-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1716 (Wrong + reporting of leak with close() in a while loop condition) + +2010-05-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1715 (switch + with fallthrough and 'return' confuses cppcheck) + +2010-05-29 Daniel Marjamäki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1714 (Wrong + precedence for shift operators when simplifying calculations?) + +2010-05-29 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Memory leaks: + enabled the leaks checking when members are not deallocated in the + destructor. This checking was previously an --all check so there + could be false positives. + +2010-05-29 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: astyle + formatting + +2010-05-29 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp: the virtual destructor + error message needs to be restricted. marked the checking as + inconclusive for now. + +2010-05-28 Zachary Blair + + * : commit 1a25183e8fb5c47c24c6c507e7fad3a0e63fbc28 Author: Robert + Reif Date: Sat May 29 07:52:06 2010 +0200 + +2010-05-28 Zachary Blair + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed #818 + (Detect sprintf buffer overrun with struct members) + +2010-05-29 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1713 (remove + Microsoft variants of inline) + +2010-05-28 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1671 + (simplifyTypedef: support for more typedefs) + +2010-05-27 Daniel Marjamäki + + * lib/executionpath.cpp, test/testother.cpp: Fixed #1712 (False + negative: dereferencing uninitialized pointer) + +2010-05-27 Robert Reif + + * lib/tokenize.cpp, lib/tokenize.h, test/testtokenize.cpp: Fixed + #1711 (Wrong typedef name shown when struct declared with + __attribute__) + +2010-05-27 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1671 + (simplifyTypedef: support for more typedefs) + +2010-05-26 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1709 (char + buffer that is only accessed with pointers is marker not assigned) + +2010-05-26 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: astyle + formatting + +2010-05-26 Daniel Marjamäki + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Fixed + #1704 (false negative: null pointer dereference) + +2010-05-26 Zachary Blair + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Fixed #168 (buffer overflow: not enough + room for the null terminator) + +2010-05-25 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1671 + (simplifyTypedef: support for more typedefs) + +2010-05-25 Robert Reif + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1708 (False + positive for const) + +2010-05-24 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1707 (false + positive: Memory leak) + +2010-05-24 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp: Removed TODO + +2010-05-23 Daniel Marjamäki + + * test/testclass.cpp: Unit Testing: Added a few more test cases + related to ticket #1700 + +2010-05-23 Daniel Marjamäki + + * test/testclass.cpp: Unit Testing: Added test case for ticket 1700 + +2010-05-23 Daniel Marjamäki + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + Tokenizer: Removed the Tokenizer::simplifyNamespaces. Ticket: #1700 + +2010-05-23 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1671 + (simplifyTypedef: support for more typedefs) + +2010-05-23 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: false positive: + Variable is assigned a value that is never used + +2010-05-21 Daniel Marjamäki + + * lib/cppcheck.cpp, lib/cppcheck.h: 2 pass checking: broke out + Cppcheck::analyseFile. To be used for tests + +2010-05-21 Daniel Marjamäki + + * lib/check.h, lib/checkother.cpp, lib/checkother.h, + lib/cppcheck.cpp, lib/settings.cpp, lib/settings.h, + test/testother.cpp: Added some multipass checking for the + uninitialized variables. It is still experimental. You can activate + it with the '--test-2-pass' switch. Some more refactorings are + needed to make it truly usable, the main thing is to make it thread + safe. + +2010-05-21 Daniel Marjamäki + + * lib/tokenize.cpp: fixed gcc compiler warnings (comparing float + values) + +2010-05-21 Daniel Marjamäki + + * lib/tokenize.cpp: Fixed gcc compiler warning + +2010-05-21 Robert Reif + + * lib/preprocessor.cpp: Fixed #1698 (Add define support to GUI) + +2010-05-21 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: give dead pointer a value + +2010-05-20 Robert Reif + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1699 (False + positive: The function '...' can be const) + +2010-05-20 Robert Reif + + * gui/mainwindow.cpp, gui/projectfile.cpp, gui/projectfile.h, + gui/projectfile.txt: Fixed #1698 (Add define support to GUI) + +2010-05-20 Robert Reif + + * lib/checkclass.cpp, test/testclass.cpp: #1697 (false positive: The + function can be const) + +2010-05-19 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #1695 (Ticket #1614 is broken using latest from git) + +2010-05-18 Daniel Marjamäki + + * lib/executionpath.cpp: printchecks: better explanation of its + purpose. I call it from gdb when I debug ExecutionPaths. + +2010-05-18 Daniel Marjamäki + + * lib/checkmemoryleak.cpp: astyle formatting + +2010-05-18 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1646 (False + positive: array access after return cannot have default loop value) + +2010-05-18 firewave + + * lib/checkother.cpp, lib/executionpath.cpp: Avoid some Visual + Studio warnings + +2010-05-18 firewave + + * .gitignore: Added ipch output folder to ignore list + +2010-05-18 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1691 (False + positive: Function parameter 'x' is passed by value. It could be + passed by reference instead.) + +2010-05-17 Zachary Blair + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, lib/tokenize.cpp, + test/testmemleak.cpp: Fixed #1649 (add a warning for potential + memory leaks when using realloc) + +2010-05-18 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1685 + (segmentation fault of cppcheck) + +2010-05-17 Daniel Marjamäki + + * gui/mainwindow.cpp: Fixed #1689 (failed to build gui) + +2010-05-17 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1673 + (Tokenizer::simplifyTypedef causes segfault for boost library) + +2010-05-17 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: astyle + formatting + +2010-05-17 Daniel Marjamäki + + * lib/tokenize.cpp: Tokenizer: it is bad to do: + 'tok->previous()->deleteThis()' + +2010-05-17 Daniel Marjamäki + + * test/test.vcproj: Visual Studio 2008: Updated test project + +2010-05-17 Daniel Marjamäki + + * test/testcppcheck.cpp: asd + +2010-05-16 Monika Lukow + + * lib/checkbufferoverrun.cpp, test/testbufferoverrun.cpp: Fixed + #1418 (false negative: buffer access out of bounds) + +2010-05-16 Erik Lax + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1683 (false + positive: The function can be const) + +2010-05-16 Daniel Marjamäki + + * lib/tokenize.cpp, test/testtokenize.cpp: Fixed #1684 (false + positive: buffer access out of bounds when using extern variable + declaration) + +2010-05-16 Daniel Marjamäki + + * lib/check.h, lib/errorlogger.h: Refactoring: Removed + 'possibleError' + +2010-05-16 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + test/testmemleak.cpp: Refactoring: Removed possibleError messages + from CheckMemoryLeaks + +2010-05-16 Erik Lax + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1688 + (Tokenizer::simplifyKnownVariables and pointer assignments) + +2010-05-16 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Refactoring: Removed 'possible error' + message about cin + +2010-05-16 Daniel Marjamäki + + * lib/checkbufferoverrun.cpp, lib/checkbufferoverrun.h, + test/testbufferoverrun.cpp: Refactoring: Removed some inconclusive + checking in CheckBufferOverrun + +2010-05-16 Daniel Marjamäki + + * lib/check.h, lib/checkclass.cpp, lib/checkclass.h, + lib/checkother.cpp, lib/checkother.h, lib/checkstl.cpp, + lib/errorlogger.h, test/testclass.cpp, test/testdivision.cpp, + test/testother.cpp, test/teststl.cpp: Refactoring: Removed + Severity::possibleStyle + +2010-05-16 Daniel Marjamki + + * lib/cppcheck.cpp, man/manual.docbook: doc: updated docs about -D + command line flag + +2010-05-16 Daniel Marjamki + + * lib/cppcheck.cpp, lib/settings.h, test/testcppcheck.cpp: Fixed + #1212 (Allow giving used defines in command line) + +2010-05-16 Daniel Marjamki + + * lib/checkexceptionsafety.cpp, lib/checkmemoryleak.cpp, + lib/cppcheck.cpp, lib/settings.cpp, lib/settings.h, + test/testexceptionsafety.cpp, test/testmemleak.cpp: Code cleanup: + Removed autodealloc handling + +2010-05-15 Daniel Marjamki + + * lib/checkclass.cpp, test/testclass.cpp: Fixed #1678 (false + positive: Member variable not initialized in the constructor, for + arrays of undefined type) + +2010-05-15 Erik Lax + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #1679 (Bad iterators + checks fails to detect bugs with indent levels) + +2010-05-15 Erik Lax + + * lib/checkstl.cpp, lib/checkstl.h, test/teststl.cpp: Fixed #1680 + (Bad iterators checks fail to detect invalidation of iterator for + deletion by value) + +2010-05-15 Daniel Marjamki + + * lib/checkmemoryleak.cpp, lib/checkmemoryleak.h, + test/testmemleak.cpp: Fixed #1681 (false negative: memory leak in + operator =) + +2010-05-15 Daniel Marjamki + + * lib/checkother.cpp, lib/checkother.h, test/testother.cpp: Added + test CheckOther::sizeofsizeof. Inspired by #1682 + +2010-05-14 Daniel Marjamki + + * lib/mathlib.cpp, test/testsuite.cpp: astyle formatting + +2010-05-14 Daniel Marjamki + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1682 + (Internal error) + +2010-05-13 Konrad Windszus + + * Makefile, lib/checkstl.cpp, lib/cppcheck.cpp, + test/testcppcheck.cpp, test/testsuite.cpp, test/testsuite.h, + test/tinyxml/changes.txt, test/tinyxml/tinystr.cpp, + test/tinyxml/tinystr.h, test/tinyxml/tinyxml.cpp, + test/tinyxml/tinyxml.h, test/tinyxml/tinyxmlerror.cpp, + test/tinyxml/tinyxmlparser.cpp: Ticket #1318: Make sure error ids + are unique + +2010-05-13 Robert Reif + + * lib/tokenize.cpp, lib/tokenize.h, test/testsimplifytokens.cpp: + Fixed #1677 (False positive: (style) Variable 'xxx' is assigned a + value that is never used) + +2010-05-12 Martin Ettl + + * lib/mathlib.cpp, test/testmathlib.cpp: mathlib:isInt() now handles + calles of 'u' and 'l' correctly; testcases added + +2010-05-11 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1671 + (simplifyTypedef: support for more typedefs) + +2010-05-10 Reijo Tomperi + + * man/cppcheck.1.xml: Update man page + +2010-05-10 Daniel Marjamäki + + * lib/checkclass.cpp, test/testclass.cpp, test/testconstructors.cpp: + Fixed #1669 (Still seeing 'possible style' warnings in 1.43) + +2010-05-10 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1665 ('If + you see this, there is a bug': Token::Match('%var% ( %varid% [,)]', + 0)) + +2010-05-10 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Better handling of + function pointer typedef + +2010-05-10 Robert Reif + + * lib/tokenize.cpp, test/testsimplifytokens.cpp: Fixed #1666 + (simplifyTypedef: add support for typedefs of functions) + +2010-05-09 Daniel Marjamäki + + * lib/checkmemoryleak.cpp, test/testmemleak.cpp: Fixed #1648 + (mismatch allocate and deallocate calls.) + +2010-05-09 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1662 (false + positive: Data is allocated but not initialized, when using sprintf) + +2010-05-09 Robert Reif + + * lib/checkother.cpp, test/testunusedvar.cpp: Fixed #1660 (false + positive: Variable is assigned a value that is never used, when + using cast) + +2010-05-09 Robert Reif + + * test/testunusedvar.cpp: Added unit test for #5 + +2010-05-08 Daniel Marjamäki + + * lib/checkstl.cpp, test/teststl.cpp: Fixed #1656 (dangerous usage + of erase not detected: for (; it != it2; ++it) ints.erase(it);) + +2010-05-08 Daniel Marjamäki + + * lib/checkother.cpp, test/testother.cpp: Fixed #1658 (false + negative: uninitialized pointer usage) + +2010-05-08 Daniel Marjamäki + + * createrelease: createrelease: more details about dmake + +2010-05-08 Daniel Marjamäki + + * Makefile: Makefile: Set debug mode + +2010-05-08 Daniel Marjamäki + + * Makefile: Makefile: Set release mode + +2010-05-08 Daniel Marjamäki + + * Changelog, createrelease: Changelog: Updated for release + 2010-05-08 Daniel Marjamäki * tools/dmake.cpp: dmake: updated compiler flags in release mode. From 3b391398c18ce7b135f291fde6db103538442f86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Jul 2010 11:31:07 +0200 Subject: [PATCH 17/29] 1.44: updated Makefile for release --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 53e96e9d5..2b83cad71 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -g -D_GLIBCXX_DEBUG +CXXFLAGS=-O2 -DNDEBUG -Wall CXX=g++ BIN=${DESTDIR}/usr/bin From 78b8acfc8854c1684c0fd991d27922972358825f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 10 Jul 2010 11:35:37 +0200 Subject: [PATCH 18/29] Makefile: debug mode --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2b83cad71..53e96e9d5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CXXFLAGS=-O2 -DNDEBUG -Wall +CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -g -D_GLIBCXX_DEBUG CXX=g++ BIN=${DESTDIR}/usr/bin From 81449a823a222f3739b12a3a6f01d47b6bb78474 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 13:53:44 +0300 Subject: [PATCH 19/29] GUI: Refactoring xmlreport to use pointer to stream writing class. --- gui/xmlreport.cpp | 30 ++++++++++++++++-------------- gui/xmlreport.h | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index f597bd54a..41dbfe5f3 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -21,12 +21,14 @@ #include "xmlreport.h" XmlReport::XmlReport(const QString &filename, QObject * parent) : - Report(filename, parent) + Report(filename, parent), + mXmlWriter(NULL) { } XmlReport::~XmlReport() { + delete mXmlWriter; Close(); } @@ -35,7 +37,7 @@ bool XmlReport::Create() bool success = false; if (Report::Create()) { - mXmlWriter.setDevice(Report::GetFile()); + mXmlWriter = new QXmlStreamWriter(Report::GetFile()); success = true; } return success; @@ -43,15 +45,15 @@ bool XmlReport::Create() void XmlReport::WriteHeader() { - mXmlWriter.setAutoFormatting(true); - mXmlWriter.writeStartDocument(); - mXmlWriter.writeStartElement("results"); + mXmlWriter->setAutoFormatting(true); + mXmlWriter->writeStartDocument(); + mXmlWriter->writeStartElement("results"); } void XmlReport::WriteFooter() { - mXmlWriter.writeEndElement(); - mXmlWriter.writeEndDocument(); + mXmlWriter->writeEndElement(); + mXmlWriter->writeEndDocument(); } void XmlReport::WriteError(const QStringList &files, const QStringList &lines, @@ -63,11 +65,11 @@ void XmlReport::WriteError(const QStringList &files, const QStringList &lines, The callstack seems to be ignored here aswell, instead last item of the stack is used */ - mXmlWriter.writeStartElement("error"); - mXmlWriter.writeAttribute("file", files[files.size() - 1]); - mXmlWriter.writeAttribute("line", lines[lines.size() - 1]); - mXmlWriter.writeAttribute("id", id); - mXmlWriter.writeAttribute("severity", severity); - mXmlWriter.writeAttribute("msg", msg); - mXmlWriter.writeEndElement(); + mXmlWriter->writeStartElement("error"); + mXmlWriter->writeAttribute("file", files[files.size() - 1]); + mXmlWriter->writeAttribute("line", lines[lines.size() - 1]); + mXmlWriter->writeAttribute("id", id); + mXmlWriter->writeAttribute("severity", severity); + mXmlWriter->writeAttribute("msg", msg); + mXmlWriter->writeEndElement(); } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index ab017b43e..cacdd4dec 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -68,7 +68,7 @@ private: /** * @brief XML stream writer for writing the report in XML format. */ - QXmlStreamWriter mXmlWriter; + QXmlStreamWriter *mXmlWriter; }; /// @} #endif // XML_REPORT_H From 5e14abf735df761cf58ecdb3a5b854b045acc1f1 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 16:37:36 +0300 Subject: [PATCH 20/29] GUI: Read errors from report XML file. This commits adds new "Open XML" item to File-menu. Selecting this menuitem allows user to select report file to open. When the file is read the error data is printed to debug output. Later patches will implement adding error data back to the GUI. --- gui/main.ui | 6 +++ gui/mainwindow.cpp | 17 +++++++++ gui/mainwindow.h | 6 +++ gui/report.cpp | 11 ++++++ gui/report.h | 6 +++ gui/resultsview.cpp | 26 +++++++++++++ gui/resultsview.h | 8 ++++ gui/xmlreport.cpp | 91 +++++++++++++++++++++++++++++++++++++++++---- gui/xmlreport.h | 22 +++++++++++ 9 files changed, 186 insertions(+), 7 deletions(-) diff --git a/gui/main.ui b/gui/main.ui index 3e0a708c3..3317d4452 100644 --- a/gui/main.ui +++ b/gui/main.ui @@ -73,6 +73,7 @@ &File + @@ -347,6 +348,11 @@ Error categories + + + &Open XML... + + diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index 15d4b08de..81acef2b7 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -56,6 +56,7 @@ MainWindow::MainWindow() : connect(mUI.mActionCheckDirectory, SIGNAL(triggered()), this, SLOT(CheckDirectory())); connect(mUI.mActionSettings, SIGNAL(triggered()), this, SLOT(ProgramSettings())); connect(mUI.mActionClearResults, SIGNAL(triggered()), this, SLOT(ClearResults())); + connect(mUI.mActionOpenXML, SIGNAL(triggered()), this, SLOT(OpenXML())); connect(mUI.mActionShowStyle, SIGNAL(toggled(bool)), this, SLOT(ShowStyle(bool))); connect(mUI.mActionShowErrors, SIGNAL(toggled(bool)), this, SLOT(ShowErrors(bool))); @@ -431,6 +432,22 @@ void MainWindow::ClearResults() mUI.mActionSave->setEnabled(false); } +void MainWindow::OpenXML() +{ + QString selectedFilter; + QString filter(tr("XML files (*.xml)")); + QString selectedFile = QFileDialog::getOpenFileName(this, + tr("Open the report file"), + QString(), + filter, + &selectedFilter); + + if (!selectedFile.isEmpty()) + { + mUI.mResults->ReadErrorsXml(selectedFile); + } +} + void MainWindow::EnableCheckButtons(bool enable) { mUI.mActionStop->setEnabled(!enable); diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 0fa17db2d..3142dccaa 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -67,6 +67,12 @@ public slots: */ void ClearResults(); + /** + * @brief Slot to open XML report file + * + */ + void OpenXML(); + /** * @brief Show errors with type "style" * @param checked Should errors be shown (true) or hidden (false) diff --git a/gui/report.cpp b/gui/report.cpp index 0fbfc4e54..cd2c911bd 100644 --- a/gui/report.cpp +++ b/gui/report.cpp @@ -41,6 +41,17 @@ bool Report::Create() return succeed; } +bool Report::Open() +{ + bool succeed = false; + if (!mFile.isOpen()) + { + mFile.setFileName(mFilename); + succeed = mFile.open(QIODevice::ReadOnly | QIODevice::Text); + } + return succeed; +} + void Report::Close() { if (mFile.isOpen()) diff --git a/gui/report.h b/gui/report.h index 5459e31ee..9e8972951 100644 --- a/gui/report.h +++ b/gui/report.h @@ -50,6 +50,12 @@ public: */ virtual bool Create(); + /** + * @brief Open the existing report (file). + * @return true if succeeded, false if file could not be created. + */ + virtual bool Open(); + /** * @brief Close the report (file). */ diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index f0f3e37f2..9c3b14a77 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -217,3 +217,29 @@ void ResultsView::DisableProgressbar() { mUI.mProgress->setEnabled(false); } + +void ResultsView::ReadErrorsXml(const QString &filename) +{ + XmlReport *report = new XmlReport(filename, this); + if (report) + { + if (report->Open()) + report->Read(); + else + { + QMessageBox msgBox; + msgBox.setText(tr("Failed to read the report.")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); + } + delete report; + report = NULL; + } + else + { + QMessageBox msgBox; + msgBox.setText(tr("Failed to read the report.")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.exec(); + } +} diff --git a/gui/resultsview.h b/gui/resultsview.h index cb3f4abb1..6b9161581 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -129,6 +129,14 @@ public: void Translate(); void DisableProgressbar(); + + /** + * @brief Read errors from report XML file. + * @param filename Report file to read. + * + */ + void ReadErrorsXml(const QString &filename); + signals: /** diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index 41dbfe5f3..30d0e2d6b 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -18,16 +18,27 @@ #include #include +#include #include "xmlreport.h" +static const char ResultElementName[] = "results"; +static const char ErrorElementName[] = "error"; +static const char FilenameAttribute[] = "file"; +static const char LineAttribute[] = "line"; +static const char IdAttribute[] = "id"; +static const char SeverityAttribute[] = "severity"; +static const char MsgAttribute[] = "msg"; + XmlReport::XmlReport(const QString &filename, QObject * parent) : Report(filename, parent), + mXmlReader(NULL), mXmlWriter(NULL) { } XmlReport::~XmlReport() { + delete mXmlReader; delete mXmlWriter; Close(); } @@ -43,11 +54,22 @@ bool XmlReport::Create() return success; } +bool XmlReport::Open() +{ + bool success = false; + if (Report::Open()) + { + mXmlReader = new QXmlStreamReader(Report::GetFile()); + success = true; + } + return success; +} + void XmlReport::WriteHeader() { mXmlWriter->setAutoFormatting(true); mXmlWriter->writeStartDocument(); - mXmlWriter->writeStartElement("results"); + mXmlWriter->writeStartElement(ResultElementName); } void XmlReport::WriteFooter() @@ -65,11 +87,66 @@ void XmlReport::WriteError(const QStringList &files, const QStringList &lines, The callstack seems to be ignored here aswell, instead last item of the stack is used */ - mXmlWriter->writeStartElement("error"); - mXmlWriter->writeAttribute("file", files[files.size() - 1]); - mXmlWriter->writeAttribute("line", lines[lines.size() - 1]); - mXmlWriter->writeAttribute("id", id); - mXmlWriter->writeAttribute("severity", severity); - mXmlWriter->writeAttribute("msg", msg); + mXmlWriter->writeStartElement(ErrorElementName); + mXmlWriter->writeAttribute(FilenameAttribute, files[files.size() - 1]); + mXmlWriter->writeAttribute(LineAttribute, lines[lines.size() - 1]); + mXmlWriter->writeAttribute(IdAttribute, id); + mXmlWriter->writeAttribute(SeverityAttribute, severity); + mXmlWriter->writeAttribute(MsgAttribute, msg); mXmlWriter->writeEndElement(); } + +void XmlReport::Read() +{ + bool insideResults = false; + if (!mXmlReader) + { + qDebug() << "You must Open() the file before reading it!"; + return; + } + while (!mXmlReader->atEnd()) + { + switch (mXmlReader->readNext()) + { + case QXmlStreamReader::StartElement: + if (mXmlReader->name() == ResultElementName) + insideResults = true; + + // Read error element from inside result element + if (insideResults && mXmlReader->name() == ErrorElementName) + ReadError(mXmlReader); + break; + + case QXmlStreamReader::EndElement: + if (mXmlReader->name() == ResultElementName) + insideResults = false; + break; + + // Not handled + case QXmlStreamReader::NoToken: + case QXmlStreamReader::Invalid: + case QXmlStreamReader::StartDocument: + case QXmlStreamReader::EndDocument: + case QXmlStreamReader::Characters: + case QXmlStreamReader::Comment: + case QXmlStreamReader::DTD: + case QXmlStreamReader::EntityReference: + case QXmlStreamReader::ProcessingInstruction: + break; + } + } +} + +void XmlReport::ReadError(QXmlStreamReader *reader) +{ + if (reader->name().toString() == ErrorElementName) + { + QXmlStreamAttributes attribs = reader->attributes(); + QString filename = attribs.value("", FilenameAttribute).toString(); + QString line = attribs.value("", LineAttribute).toString(); + QString id = attribs.value("", IdAttribute).toString(); + QString severity = attribs.value("", SeverityAttribute).toString(); + QString msg = attribs.value("", MsgAttribute).toString(); + qDebug() << "Error: " << filename << " " << line << " " << id << " " << severity << " " << msg; + } +} diff --git a/gui/xmlreport.h b/gui/xmlreport.h index cacdd4dec..06c0fbf35 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "report.h" @@ -47,6 +48,11 @@ public: */ virtual bool Create(); + /** + * @brief Open existing report file. + */ + bool Open(); + /** * @brief Write report header. */ @@ -63,7 +69,23 @@ public: virtual void WriteError(const QStringList &files, const QStringList &lines, const QString &id, const QString &severity, const QString &msg); + /** + * @brief Read contents of the report file. + */ + void Read(); + +protected: + /** + * @brief Read and parse error item from XML stream. + * @param reader XML stream reader to use. + */ + void ReadError(QXmlStreamReader *reader); + private: + /** + * @brief XML stream reader for reading the report in XML format. + */ + QXmlStreamReader *mXmlReader; /** * @brief XML stream writer for writing the report in XML format. From 0e9d0e9bde155e2bfa5a87deb648571c3389a3b2 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 18:20:45 +0300 Subject: [PATCH 21/29] GUI: Refactor error data passing to use own class. --- gui/csvreport.cpp | 9 +++------ gui/csvreport.h | 5 ++--- gui/report.h | 18 +++++++++++++++--- gui/resultstree.cpp | 22 +++++++++------------- gui/txtreport.cpp | 15 ++++++--------- gui/txtreport.h | 5 ++--- gui/xmlreport.cpp | 13 ++++++------- gui/xmlreport.h | 4 ++-- 8 files changed, 45 insertions(+), 46 deletions(-) diff --git a/gui/csvreport.cpp b/gui/csvreport.cpp index 7a4c5efab..db47fcdb2 100644 --- a/gui/csvreport.cpp +++ b/gui/csvreport.cpp @@ -51,19 +51,16 @@ void CsvReport::WriteFooter() // No footer for CSV report } -void CsvReport::WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, const QString &msg) +void CsvReport::WriteError(const ErrorItem &error) { - Q_UNUSED(id); - /* Error as CSV line gui/test.cpp,23,error,Mismatching allocation and deallocation: k */ QString line; - line += QString("%1,%2,").arg(files[files.size() - 1]).arg(lines[lines.size() - 1]); - line += QString("%1,%2").arg(severity).arg(msg); + line += QString("%1,%2,").arg(error.files[error.files.size() - 1]).arg(error.lines[error.lines.size() - 1]); + line += QString("%1,%2").arg(error.severity).arg(error.msg); mTxtWriter << line << endl; } diff --git a/gui/csvreport.h b/gui/csvreport.h index 23e3eadef..5661a03d5 100644 --- a/gui/csvreport.h +++ b/gui/csvreport.h @@ -60,10 +60,9 @@ public: /** * @brief Write error to report. + * @param error Error data. */ - virtual void WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, - const QString &msg); + virtual void WriteError(const ErrorItem &error); private: diff --git a/gui/report.h b/gui/report.h index 9e8972951..386911dd0 100644 --- a/gui/report.h +++ b/gui/report.h @@ -27,6 +27,19 @@ /// @addtogroup GUI /// @{ +/** +* @brief A class containing error data. +*/ +class ErrorItem +{ +public: + QStringList files; + QStringList lines; + QString id; + QString severity; + QString msg; +}; + /** * @brief A base class for reports. */ @@ -73,10 +86,9 @@ public: /** * @brief Write error to report. + * @param error Error data. */ - virtual void WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, - const QString &msg) = 0; + virtual void WriteError(const ErrorItem &error) = 0; protected: diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index e69138a81..a01785b59 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -601,8 +601,6 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) return; } - //qDebug() << item->text() << "has" << item->rowCount() << "errors"; - for (int i = 0; i < item->rowCount(); i++) { QStandardItem *error = item->child(i, 0); @@ -622,17 +620,15 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) //Convert it to QVariantMap QVariantMap data = userdata.toMap(); - QString severity = ShowTypeToString(VariantToShowType(data["severity"])); - QString message = data["message"].toString(); - QString id = data["id"].toString(); + ErrorItem item; + item.severity = ShowTypeToString(VariantToShowType(data["severity"])); + item.msg = data["message"].toString(); + item.id = data["id"].toString(); QString file = StripPath(data["file"].toString(), true); QString line = data["line"].toString(); - QStringList files; - QStringList lines; - - files << file; - lines << line; + item.files << file; + item.lines << line; for (int j = 0; j < error->rowCount(); j++) { @@ -645,11 +641,11 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) file = StripPath(child_data["file"].toString(), true); line = child_data["line"].toString(); - files << file; - lines << line; + item.files << file; + item.lines << line; } - report->WriteError(files, lines, id, severity, message); + report->WriteError(item); } } diff --git a/gui/txtreport.cpp b/gui/txtreport.cpp index 0cf4728ba..0a064f354 100644 --- a/gui/txtreport.cpp +++ b/gui/txtreport.cpp @@ -51,11 +51,8 @@ void TxtReport::WriteFooter() // No footer for txt report } -void TxtReport::WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, const QString &msg) +void TxtReport::WriteError(const ErrorItem &error) { - Q_UNUSED(id); - /* Error example from the core program in text [gui/test.cpp:23] -> [gui/test.cpp:14]: (error) Mismatching allocation and deallocation: k @@ -63,21 +60,21 @@ void TxtReport::WriteError(const QStringList &files, const QStringList &lines, QString line; - for (int i = 0; i < lines.size(); i++) + for (int i = 0; i < error.lines.size(); i++) { - line += QString("[%1:%2]").arg(files[i]).arg(lines[i]); - if (i < lines.size() - 1 && lines.size() > 0) + line += QString("[%1:%2]").arg(error.files[i]).arg(error.lines[i]); + if (i < error.lines.size() - 1 && error.lines.size() > 0) { line += " -> "; } - if (i == lines.size() - 1) + if (i == error.lines.size() - 1) { line += ": "; } } - line += QString("(%1) %2").arg(severity).arg(msg); + line += QString("(%1) %2").arg(error.severity).arg(error.msg); mTxtWriter << line << endl; } diff --git a/gui/txtreport.h b/gui/txtreport.h index f3035536a..8dab58622 100644 --- a/gui/txtreport.h +++ b/gui/txtreport.h @@ -58,10 +58,9 @@ public: /** * @brief Write error to report. + * @param error Error data. */ - virtual void WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, - const QString &msg); + virtual void WriteError(const ErrorItem &error); private: diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index 30d0e2d6b..d8b5d2212 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -78,8 +78,7 @@ void XmlReport::WriteFooter() mXmlWriter->writeEndDocument(); } -void XmlReport::WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, const QString &msg) +void XmlReport::WriteError(const ErrorItem &error) { /* Error example from the core program in xml @@ -88,11 +87,11 @@ void XmlReport::WriteError(const QStringList &files, const QStringList &lines, */ mXmlWriter->writeStartElement(ErrorElementName); - mXmlWriter->writeAttribute(FilenameAttribute, files[files.size() - 1]); - mXmlWriter->writeAttribute(LineAttribute, lines[lines.size() - 1]); - mXmlWriter->writeAttribute(IdAttribute, id); - mXmlWriter->writeAttribute(SeverityAttribute, severity); - mXmlWriter->writeAttribute(MsgAttribute, msg); + mXmlWriter->writeAttribute(FilenameAttribute, error.files[error.files.size() - 1]); + mXmlWriter->writeAttribute(LineAttribute, error.lines[error.lines.size() - 1]); + mXmlWriter->writeAttribute(IdAttribute, error.id); + mXmlWriter->writeAttribute(SeverityAttribute, error.severity); + mXmlWriter->writeAttribute(MsgAttribute, error.msg); mXmlWriter->writeEndElement(); } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 06c0fbf35..5cc99d769 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -65,9 +65,9 @@ public: /** * @brief Write error to report. + * @param error Error data. */ - virtual void WriteError(const QStringList &files, const QStringList &lines, - const QString &id, const QString &severity, const QString &msg); + virtual void WriteError(const ErrorItem &error); /** * @brief Read contents of the report file. From 2f0202d1051b517b1954f95158e8497adb680051 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 20:30:31 +0300 Subject: [PATCH 22/29] GUI: More refactoring to use ErrorItem and ErrorLine. --- gui/erroritem.h | 56 +++++++++++++++++++++++++++++++ gui/gui.pro | 1 + gui/report.h | 14 +------- gui/resultstree.cpp | 82 ++++++++++++++++++++------------------------- gui/resultstree.h | 28 ++++------------ gui/resultsview.cpp | 15 ++++++++- 6 files changed, 116 insertions(+), 80 deletions(-) create mode 100644 gui/erroritem.h diff --git a/gui/erroritem.h b/gui/erroritem.h new file mode 100644 index 000000000..a5eb88abb --- /dev/null +++ b/gui/erroritem.h @@ -0,0 +1,56 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef ERRORITEM_H +#define ERRORITEM_H + +#include +#include + +/// @addtogroup GUI +/// @{ + +/** +* @brief A class containing error data for one error. +*/ +class ErrorItem +{ +public: + QString file; + QStringList files; + QStringList lines; + QString id; + QString severity; + QString msg; +}; + +/** +* @brief A class containing error data for one shown error line. +*/ +class ErrorLine +{ +public: + QString file; + QString line; + QString id; + QString severity; + QString msg; +}; + +/// @} +#endif // ERRORITEM_H diff --git a/gui/gui.pro b/gui/gui.pro index 0ef54b270..d0c23068c 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -50,6 +50,7 @@ HEADERS += mainwindow.h \ applicationdialog.h \ aboutdialog.h \ common.h \ + erroritem.h \ fileviewdialog.h \ projectfile.h \ report.h \ diff --git a/gui/report.h b/gui/report.h index 386911dd0..83a22e148 100644 --- a/gui/report.h +++ b/gui/report.h @@ -23,23 +23,11 @@ #include #include #include +#include "erroritem.h" /// @addtogroup GUI /// @{ -/** -* @brief A class containing error data. -*/ -class ErrorItem -{ -public: - QStringList files; - QStringList lines; - QString id; - QString severity; - QString msg; -}; - /** * @brief A base class for reports. */ diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index a01785b59..096c6e94c 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "erroritem.h" #include "resultstree.h" #include "xmlreport.h" @@ -67,28 +68,21 @@ QStandardItem *ResultsTree::CreateItem(const QString &name) return item; } -void ResultsTree::AddErrorItem(const QString &file, - const QString &severity, - const QString &message, - const QStringList &files, - const QVariantList &lines, - const QString &id) +void ResultsTree::AddErrorItem(const ErrorItem &item) { - Q_UNUSED(file); - - if (files.isEmpty()) + if (item.files.isEmpty()) { return; } - QString realfile = StripPath(files[0], false); + QString realfile = StripPath(item.files[0], false); if (realfile.isEmpty()) { realfile = tr("Undefined file"); } - bool hide = !mShowTypes[SeverityToShowType(severity)]; + bool hide = !mShowTypes[SeverityToShowType(item.severity)]; //if there is at least one error that is not hidden, we have a visible error if (!hide) @@ -96,48 +90,49 @@ void ResultsTree::AddErrorItem(const QString &file, mVisibleErrors = true; } + ErrorLine line; + line.file = realfile; + line.id = item.id; + line.line = item.lines[0]; + line.msg = item.msg; + line.severity = item.severity; //Create the base item for the error and ensure it has a proper //file item as a parent - QStandardItem *item = AddBacktraceFiles(EnsureFileItem(files[0], hide), - realfile, - lines[0].toInt(), - severity, - message, - hide, - SeverityToIcon(severity)); + QStandardItem *stditem = AddBacktraceFiles(EnsureFileItem(line.file, hide), + line, + hide, + SeverityToIcon(line.severity)); - if (!item) + if (!stditem) return; //Add user data to that item QMap data; - data["severity"] = SeverityToShowType(severity); - data["message"] = message; - data["file"] = files[0]; - data["line"] = lines[0]; - data["id"] = id; - item->setData(QVariant(data)); + data["severity"] = SeverityToShowType(line.severity); + data["message"] = line.msg; + data["file"] = line.file; + data["line"] = line.line; + data["id"] = line.id; + stditem->setData(QVariant(data)); //Add backtrace files as children - for (int i = 1; i < files.size() && i < lines.size(); i++) + for (int i = 1; i < item.files.size() && i < item.lines.size(); i++) { + line.file = item.files[i]; + line.line = item.lines[i]; QStandardItem *child_item; - - child_item = AddBacktraceFiles(item, - StripPath(files[i], false), - lines[i].toInt(), - severity, - message, + child_item = AddBacktraceFiles(stditem, + line, hide, ":images/go-down.png"); //Add user data to that item QMap child_data; - child_data["severity"] = SeverityToShowType(severity); - child_data["message"] = message; - child_data["file"] = files[i]; - child_data["line"] = lines[i]; - child_data["id"] = id; + child_data["severity"] = SeverityToShowType(line.severity); + child_data["message"] = line.msg; + child_data["file"] = line.file; + child_data["line"] = line.line; + child_data["id"] = line.id; child_item->setData(QVariant(child_data)); } @@ -150,10 +145,7 @@ void ResultsTree::AddErrorItem(const QString &file, } QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, - const QString &file, - const int line, - const QString &severity, - const QString &message, + const ErrorLine &item, const bool hide, const QString &icon) @@ -164,12 +156,12 @@ QStandardItem *ResultsTree::AddBacktraceFiles(QStandardItem *parent, } QList list; - list << CreateItem(file); - list << CreateItem(tr(severity.toLatin1())); - list << CreateItem(QString("%1").arg(line)); + list << CreateItem(item.file); + list << CreateItem(tr(item.severity.toLatin1())); + list << CreateItem(QString("%1").arg(item.line)); //TODO message has parameter names so we'll need changes to the core //cppcheck so we can get proper translations - list << CreateItem(tr(message.toLatin1())); + list << CreateItem(tr(item.msg.toLatin1())); // Check for duplicate rows and don't add them if found for (int i = 0; i < parent->rowCount(); i++) diff --git a/gui/resultstree.h b/gui/resultstree.h index a234d7af0..6f2ae6620 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -25,11 +25,13 @@ #include #include #include +#include #include "common.h" #include "applicationlist.h" -#include class Report; +class ErrorItem; +class ErrorLine; /// @addtogroup GUI /// @{ @@ -50,19 +52,9 @@ public: /** * @brief Add a new item to the tree * - * @param file filename - * @param severity error severity - * @param message error message - * @param files list of files affected by the error - * @param lines list of file line numers affected by the error - * @param id error id + * @param item Error item data */ - void AddErrorItem(const QString &file, - const QString &severity, - const QString &message, - const QStringList &files, - const QVariantList &lines, - const QString &id); + void AddErrorItem(const ErrorItem &item); /** * @brief Clear all errors from the tree @@ -224,19 +216,13 @@ protected: * @brief Add a new error item beneath a file or a backtrace item beneath an error * * @param parent Parent for the item. Either a file item or an error item - * @param file Filename of the error - * @param line Line numer - * @param severity Error severity - * @param message Error message + * @param item Error line data * @param hide Should this be hidden (true) or shown (false) * @param icon Should a default backtrace item icon be added * @return newly created QStandardItem * */ QStandardItem *AddBacktraceFiles(QStandardItem *parent, - const QString &file, - const int line, - const QString &severity, - const QString &message, + const ErrorLine &item, const bool hide, const QString &icon); diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index 9c3b14a77..e13f8b6ba 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -74,7 +74,20 @@ void ResultsView::Error(const QString &file, const QString &id) { mErrorsFound = true; - mUI.mTree->AddErrorItem(file, severity, message, files, lines, id); + ErrorItem item; + item.file = file; + item.files = files; + item.id = id; + item.msg = message; + item.severity = severity; + + QVariant line; + foreach(line, lines) + { + item.lines.append(line.toString()); + } + + mUI.mTree->AddErrorItem(item); emit GotResults(); } From faa483b8d0b36a542a6b1b90508f1d3f808f3a23 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sat, 10 Jul 2010 20:54:33 +0300 Subject: [PATCH 23/29] GUI: Use integer list instead of variant list for line numbers. --- gui/erroritem.h | 2 +- gui/resultstree.cpp | 4 ++-- gui/resultsview.cpp | 9 ++------- gui/resultsview.h | 2 +- gui/threadhandler.cpp | 4 ++-- gui/threadresult.cpp | 2 +- gui/threadresult.h | 2 +- gui/xmlreport.cpp | 3 ++- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/gui/erroritem.h b/gui/erroritem.h index a5eb88abb..ed4215aad 100644 --- a/gui/erroritem.h +++ b/gui/erroritem.h @@ -33,7 +33,7 @@ class ErrorItem public: QString file; QStringList files; - QStringList lines; + QList lines; QString id; QString severity; QString msg; diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 096c6e94c..d63fe7ea8 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -617,7 +617,7 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) item.msg = data["message"].toString(); item.id = data["id"].toString(); QString file = StripPath(data["file"].toString(), true); - QString line = data["line"].toString(); + unsigned int line = data["line"].toUInt(); item.files << file; item.lines << line; @@ -631,7 +631,7 @@ void ResultsTree::SaveErrors(Report *report, QStandardItem *item) QVariantMap child_data = child_userdata.toMap(); file = StripPath(child_data["file"].toString(), true); - line = child_data["line"].toString(); + line = child_data["line"].toUInt(); item.files << file; item.lines << line; diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index e13f8b6ba..aeab7e85f 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -70,7 +70,7 @@ void ResultsView::Error(const QString &file, const QString &severity, const QString &message, const QStringList &files, - const QVariantList &lines, + const QList &lines, const QString &id) { mErrorsFound = true; @@ -78,15 +78,10 @@ void ResultsView::Error(const QString &file, item.file = file; item.files = files; item.id = id; + item.lines = lines; item.msg = message; item.severity = severity; - QVariant line; - foreach(line, lines) - { - item.lines.append(line.toString()); - } - mUI.mTree->AddErrorItem(item); emit GotResults(); } diff --git a/gui/resultsview.h b/gui/resultsview.h index 6b9161581..a940fdebb 100644 --- a/gui/resultsview.h +++ b/gui/resultsview.h @@ -169,7 +169,7 @@ public slots: const QString &severity, const QString &message, const QStringList &files, - const QVariantList &lines, + const QList &lines, const QString &id); /** diff --git a/gui/threadhandler.cpp b/gui/threadhandler.cpp index 2dad5df0e..feae8b503 100644 --- a/gui/threadhandler.cpp +++ b/gui/threadhandler.cpp @@ -145,13 +145,13 @@ void ThreadHandler::Initialize(ResultsView *view) const QString &, const QString &, const QStringList &, - const QVariantList &, + const QList &, const QString &)), view, SLOT(Error(const QString &, const QString &, const QString &, const QStringList &, - const QVariantList &, + const QList &, const QString &))); } diff --git a/gui/threadresult.cpp b/gui/threadresult.cpp index 56ca9ee16..165edb528 100644 --- a/gui/threadresult.cpp +++ b/gui/threadresult.cpp @@ -47,7 +47,7 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg) { QMutexLocker locker(&mutex); - QVariantList lines; + QList lines; QStringList files; for (std::list::const_iterator tok = msg._callStack.begin(); diff --git a/gui/threadresult.h b/gui/threadresult.h index c1b1b9a66..494d5db16 100644 --- a/gui/threadresult.h +++ b/gui/threadresult.h @@ -98,7 +98,7 @@ signals: const QString &severity, const QString &message, const QStringList &files, - const QVariantList &lines, + const QList &lines, const QString &id); protected: diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index d8b5d2212..56a58fbd0 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -88,7 +88,8 @@ void XmlReport::WriteError(const ErrorItem &error) mXmlWriter->writeStartElement(ErrorElementName); mXmlWriter->writeAttribute(FilenameAttribute, error.files[error.files.size() - 1]); - mXmlWriter->writeAttribute(LineAttribute, error.lines[error.lines.size() - 1]); + const QString line = QString::number(error.lines[error.lines.size() - 1]); + mXmlWriter->writeAttribute(LineAttribute, line); mXmlWriter->writeAttribute(IdAttribute, error.id); mXmlWriter->writeAttribute(SeverityAttribute, error.severity); mXmlWriter->writeAttribute(MsgAttribute, error.msg); From 352941f5dfcbdebbbeb8a40caa2b0b48f3a47a00 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 01:04:53 +0300 Subject: [PATCH 24/29] GUI: Fix transporting errors. Need to register integer list as new metatype so that Qt's type system knows how to use it. Adding also additional constructors for the ErrorItem. --- gui/erroritem.cpp | 39 +++++++++++++++++++++++++++++++++++++++ gui/erroritem.h | 6 ++++++ gui/gui.pro | 1 + gui/main.cpp | 4 ++++ 4 files changed, 50 insertions(+) create mode 100644 gui/erroritem.cpp diff --git a/gui/erroritem.cpp b/gui/erroritem.cpp new file mode 100644 index 000000000..98f620671 --- /dev/null +++ b/gui/erroritem.cpp @@ -0,0 +1,39 @@ +/* + * Cppcheck - A tool for static C/C++ code analysis + * Copyright (C) 2007-2010 Daniel Marjamki and Cppcheck team. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "erroritem.h" + +ErrorItem::ErrorItem(const ErrorItem &item) +{ + file = item.file; + files = item.files; + lines = item.lines; + id = item.id; + severity = item.severity; + msg = item.msg; +} + +ErrorItem::ErrorItem(const ErrorLine &line) +{ + file = line.file; + files.append(line.file); + lines.append(line.line.toUInt()); + id = line.id; + severity = line.severity; + msg = line.msg; +} diff --git a/gui/erroritem.h b/gui/erroritem.h index ed4215aad..73fc661d9 100644 --- a/gui/erroritem.h +++ b/gui/erroritem.h @@ -22,6 +22,8 @@ #include #include +class ErrorLine; + /// @addtogroup GUI /// @{ @@ -31,6 +33,10 @@ class ErrorItem { public: + ErrorItem() { } + ErrorItem(const ErrorItem &item); + ErrorItem(const ErrorLine &line); + QString file; QStringList files; QList lines; diff --git a/gui/gui.pro b/gui/gui.pro index d0c23068c..84265f8ea 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -71,6 +71,7 @@ SOURCES += main.cpp \ aboutdialog.cpp \ fileviewdialog.cpp \ projectfile.cpp \ + erroritem.cpp \ report.cpp \ txtreport.cpp \ xmlreport.cpp \ diff --git a/gui/main.cpp b/gui/main.cpp index 2309e7a64..02ee24eae 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "mainwindow.h" int main(int argc, char *argv[]) @@ -27,6 +28,9 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); app.setWindowIcon(QIcon(":icon.png")); + // Register this metatype that is used to transfer error info + qRegisterMetaType>("QList"); + // Set codecs so that UTF-8 strings in sources are handled correctly. QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); From 9a5166075f6f0ed039c82e925852b59fcf2db775 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 01:07:40 +0300 Subject: [PATCH 25/29] GUI: Fix line numbers and filenames in errors. When converting to use new ErrorItem and ErrorLine I made few mistakes in how I handled the data. And for some reason there was not even warnings about converting integers to QStrings. --- gui/resultstree.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index d63fe7ea8..4b14ee8d2 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -93,7 +93,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item) ErrorLine line; line.file = realfile; line.id = item.id; - line.line = item.lines[0]; + line.line = QString::number(item.lines[0]); line.msg = item.msg; line.severity = item.severity; //Create the base item for the error and ensure it has a proper @@ -108,17 +108,17 @@ void ResultsTree::AddErrorItem(const ErrorItem &item) //Add user data to that item QMap data; - data["severity"] = SeverityToShowType(line.severity); - data["message"] = line.msg; - data["file"] = line.file; - data["line"] = line.line; - data["id"] = line.id; + data["severity"] = SeverityToShowType(item.severity); + data["message"] = item.msg; + data["file"] = item.files[0]; + data["line"] = QString::number(item.lines[0]); + data["id"] = item.id; stditem->setData(QVariant(data)); //Add backtrace files as children for (int i = 1; i < item.files.size() && i < item.lines.size(); i++) { - line.file = item.files[i]; + line.file = StripPath(item.files[i], false); line.line = item.lines[i]; QStandardItem *child_item; child_item = AddBacktraceFiles(stditem, @@ -130,7 +130,7 @@ void ResultsTree::AddErrorItem(const ErrorItem &item) QMap child_data; child_data["severity"] = SeverityToShowType(line.severity); child_data["message"] = line.msg; - child_data["file"] = line.file; + child_data["file"] = item.files[i]; child_data["line"] = line.line; child_data["id"] = line.id; child_item->setData(QVariant(child_data)); From f894b192093d1e221c52720654edbdc2242ad73c Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 02:02:08 +0300 Subject: [PATCH 26/29] GUI: Add errors read from XML report to GUI. --- gui/report.cpp | 1 + gui/resultsview.cpp | 10 +++++++++- gui/xmlreport.cpp | 27 +++++++++++++++++---------- gui/xmlreport.h | 4 ++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/gui/report.cpp b/gui/report.cpp index cd2c911bd..2f5e150e3 100644 --- a/gui/report.cpp +++ b/gui/report.cpp @@ -17,6 +17,7 @@ */ #include +#include "erroritem.h" #include "report.h" Report::Report(const QString &filename, QObject * parent) : diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index aeab7e85f..e6f7a7945 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -229,10 +229,11 @@ void ResultsView::DisableProgressbar() void ResultsView::ReadErrorsXml(const QString &filename) { XmlReport *report = new XmlReport(filename, this); + QList errors; if (report) { if (report->Open()) - report->Read(); + errors = report->Read(); else { QMessageBox msgBox; @@ -250,4 +251,11 @@ void ResultsView::ReadErrorsXml(const QString &filename) msgBox.setIcon(QMessageBox::Critical); msgBox.exec(); } + + ErrorLine line; + foreach(line, errors) + { + ErrorItem item(line); + mUI.mTree->AddErrorItem(item); + } } diff --git a/gui/xmlreport.cpp b/gui/xmlreport.cpp index 56a58fbd0..57873feba 100644 --- a/gui/xmlreport.cpp +++ b/gui/xmlreport.cpp @@ -19,6 +19,7 @@ #include #include #include +#include "erroritem.h" #include "xmlreport.h" static const char ResultElementName[] = "results"; @@ -96,13 +97,14 @@ void XmlReport::WriteError(const ErrorItem &error) mXmlWriter->writeEndElement(); } -void XmlReport::Read() +QList XmlReport::Read() { + QList errors; bool insideResults = false; if (!mXmlReader) { qDebug() << "You must Open() the file before reading it!"; - return; + return errors; } while (!mXmlReader->atEnd()) { @@ -114,7 +116,10 @@ void XmlReport::Read() // Read error element from inside result element if (insideResults && mXmlReader->name() == ErrorElementName) - ReadError(mXmlReader); + { + ErrorLine line = ReadError(mXmlReader); + errors.append(line); + } break; case QXmlStreamReader::EndElement: @@ -135,18 +140,20 @@ void XmlReport::Read() break; } } + return errors; } -void XmlReport::ReadError(QXmlStreamReader *reader) +ErrorLine XmlReport::ReadError(QXmlStreamReader *reader) { + ErrorLine line; if (reader->name().toString() == ErrorElementName) { QXmlStreamAttributes attribs = reader->attributes(); - QString filename = attribs.value("", FilenameAttribute).toString(); - QString line = attribs.value("", LineAttribute).toString(); - QString id = attribs.value("", IdAttribute).toString(); - QString severity = attribs.value("", SeverityAttribute).toString(); - QString msg = attribs.value("", MsgAttribute).toString(); - qDebug() << "Error: " << filename << " " << line << " " << id << " " << severity << " " << msg; + line.file = attribs.value("", FilenameAttribute).toString(); + line.line = attribs.value("", LineAttribute).toString(); + line.id = attribs.value("", IdAttribute).toString(); + line.severity = attribs.value("", SeverityAttribute).toString(); + line.msg = attribs.value("", MsgAttribute).toString(); } + return line; } diff --git a/gui/xmlreport.h b/gui/xmlreport.h index 5cc99d769..f850707c3 100644 --- a/gui/xmlreport.h +++ b/gui/xmlreport.h @@ -72,14 +72,14 @@ public: /** * @brief Read contents of the report file. */ - void Read(); + QList Read(); protected: /** * @brief Read and parse error item from XML stream. * @param reader XML stream reader to use. */ - void ReadError(QXmlStreamReader *reader); + ErrorLine ReadError(QXmlStreamReader *reader); private: /** From b8793b15294ddb2d86360f483b8579e627f451a7 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 14:22:55 +0300 Subject: [PATCH 27/29] GUI: Ask file location from user if not found. When loading report from XML there is no full paths so the file's real path is not known and cppcheck cannot open it. So if the file has no absolute path then we ask where the file is located from the user. --- gui/resultstree.cpp | 38 +++++++++++++++++++++++++++++++++++++- gui/resultstree.h | 6 ++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 4b14ee8d2..5a230b5a8 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "erroritem.h" #include "resultstree.h" @@ -444,7 +445,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e) void ResultsTree::StartApplication(QStandardItem *target, int application) { - //If there are now application's specified, tell the user about it + //If there are no applications specified, tell the user about it if (mApplications->GetApplicationCount() == 0) { QMessageBox msg(QMessageBox::Information, @@ -468,6 +469,26 @@ void ResultsTree::StartApplication(QStandardItem *target, int application) //Replace (file) with filename QString file = data["file"].toString(); + + QFileInfo info(file); + if (!info.exists()) + { + if (info.isAbsolute()) + { + QMessageBox msgbox(this); + msgbox.setWindowTitle("Cppcheck"); + msgbox.setText(tr("Could not find the file!")); + msgbox.setIcon(QMessageBox::Critical); + msgbox.exec(); + } + else + { + QString dir = AskFileDir(file); + dir += '/'; + file = dir + file; + } + } + if (file.indexOf(" ") > -1) { file.insert(0, "\""); @@ -498,6 +519,21 @@ void ResultsTree::StartApplication(QStandardItem *target, int application) } } +QString ResultsTree::AskFileDir(const QString &file) +{ + QString text = tr("Could not find file:\n%1\nPlease select the directory where file is located.").arg(file); + QMessageBox msgbox(this); + msgbox.setWindowTitle("Cppcheck"); + msgbox.setText(text); + msgbox.setIcon(QMessageBox::Warning); + msgbox.exec(); + + QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"), + "", + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + return dir; +} + void ResultsTree::CopyFilename() { CopyPath(mContextItem, false); diff --git a/gui/resultstree.h b/gui/resultstree.h index 6f2ae6620..5f35c6f63 100644 --- a/gui/resultstree.h +++ b/gui/resultstree.h @@ -262,6 +262,12 @@ protected: */ void LoadSettings(); + /** + * @brief Ask directory where file is located. + * @param file File name. + * @return Directory user chose. + */ + QString AskFileDir(const QString &file); /** * @brief Create a new QStandardItem From c9d63fa454e6954a0ca1215b1e9b9441c2a01817 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 16:20:19 +0300 Subject: [PATCH 28/29] GUI: Remember user-selected base path. Remember the base path user selects when opening files from loaded XML report. --- gui/resultstree.cpp | 16 ++++++++++++---- gui/resultsview.cpp | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/gui/resultstree.cpp b/gui/resultstree.cpp index 5a230b5a8..bd24bb1cd 100644 --- a/gui/resultstree.cpp +++ b/gui/resultstree.cpp @@ -33,7 +33,6 @@ ResultsTree::ResultsTree(QWidget * parent) : QTreeView(parent), mContextItem(0), - mCheckPath(""), mVisibleErrors(false) { for (int i = 0; i < SHOW_NONE; i++) @@ -483,9 +482,17 @@ void ResultsTree::StartApplication(QStandardItem *target, int application) } else { - QString dir = AskFileDir(file); - dir += '/'; - file = dir + file; + QDir checkdir(mCheckPath); + if (checkdir.isAbsolute() && checkdir.exists()) + { + file = mCheckPath + "/" + file; + } + else + { + QString dir = AskFileDir(file); + dir += '/'; + file = dir + file; + } } } @@ -531,6 +538,7 @@ QString ResultsTree::AskFileDir(const QString &file) QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"), "", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + mCheckPath = dir; return dir; } diff --git a/gui/resultsview.cpp b/gui/resultsview.cpp index e6f7a7945..2e941979a 100644 --- a/gui/resultsview.cpp +++ b/gui/resultsview.cpp @@ -258,4 +258,5 @@ void ResultsView::ReadErrorsXml(const QString &filename) ErrorItem item(line); mUI.mTree->AddErrorItem(item); } + mUI.mTree->SetCheckDirectory(""); } From 8a24435db2f2133f08483b9fb3de9c76100b3d71 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Sun, 11 Jul 2010 16:33:49 +0300 Subject: [PATCH 29/29] GUI: Update translation files. --- gui/cppcheck_de.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_en.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_fi.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_nl.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_pl.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_ru.ts | 192 ++++++++++++++++++++++++++------------------- gui/cppcheck_se.ts | 192 ++++++++++++++++++++++++++------------------- 7 files changed, 791 insertions(+), 553 deletions(-) diff --git a/gui/cppcheck_de.ts b/gui/cppcheck_de.ts index ac549e951..960f7dcff 100644 --- a/gui/cppcheck_de.ts +++ b/gui/cppcheck_de.ts @@ -128,15 +128,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck - + Standard @@ -146,254 +146,265 @@ kate -l(line) (file) - + &View - + &Toolbars - + &Check - + &Edit - + &License... - + A&uthors... - + &About... - + &Files... - + Ctrl+F - + &Directory... - + Ctrl+D - + &Recheck files - + Ctrl+R - + &Stop - + Esc - + &Save results to file... - + Ctrl+S - + &Quit - + &Clear results - + &Preferences - + Show style errors - + Show common errors - + &Check all - + &Uncheck all - + Collapse &all - + &Expand all - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + &Language - + &Help - + Select files to check - + Select directory to check - + No suitable files found to check! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. - + License - + Authors - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + + XML files (*.xml) - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -463,74 +474,91 @@ Stop the checking before exiting. ResultsTree - - + + File - - + + Severity - - + + Line - - + + Message - + Undefined file - + Copy filename - + Copy full path - + Copy message - + Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style - + error @@ -538,30 +566,36 @@ Please check the application path and parameters are correct. ResultsView - - + + Cppcheck - + No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + + Failed to read the report. + + + + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_en.ts b/gui/cppcheck_en.ts index 53a7f3418..a1292eba6 100644 --- a/gui/cppcheck_en.ts +++ b/gui/cppcheck_en.ts @@ -141,15 +141,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck - + Standard Standard @@ -159,207 +159,217 @@ kate -l(line) (file) &File - + &View &View - + &Toolbars - + &Check &Check - + &Edit &Edit - + &License... &License... - + A&uthors... A&uthors... - + &About... &About... - + &Files... &Files... - + Ctrl+F Ctrl+F - + &Directory... &Directory... - + Ctrl+D Ctrl+D - + &Recheck files &Recheck files - + Ctrl+R Ctrl+R - + &Stop &Stop - + Esc Esc - + &Save results to file... &Save results to file... - + Ctrl+S Ctrl+S - + &Quit &Quit - + &Clear results &Clear results - + &Preferences &Preferences - + Show style errors Show style errors - + Show common errors Show common errors - + &Check all &Check all - + &Uncheck all &Uncheck all - + Collapse &all Collapse &all - + &Expand all &Expand all - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + &Language &Language - + &Help &Help - + Select files to check Select files to check - + Select directory to check Select directory to check - + No suitable files found to check! No suitable files found to check! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. @@ -368,47 +378,48 @@ Stop the checking before exiting. Stop the checking before exiting. - + License License - + Authors Authors - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file Save the report file - + + XML files (*.xml) XML files (*.xml) - + Text files (*.txt) Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -480,62 +491,67 @@ Stop the checking before exiting. ResultsTree - - + + File File - - + + Severity Severity - - + + Line Line - - + + Message Message - + Undefined file Undefined file - + Copy filename Copy filename - + Copy full path Copy full path - + Copy message - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. You can open this error by specifying applications in program's settings. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. @@ -544,12 +560,24 @@ Please check the application path and parameters are correct. Please check the application path and parameters are correct. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style Style - + error Error @@ -557,31 +585,37 @@ Please check the application path and parameters are correct. ResultsView - - + + Cppcheck Cppcheck - + No errors found. No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + + Failed to read the report. + + + + No errors found, nothing to save. No errors found, nothing to save. - - + + Failed to save the report. Failed to save the report. diff --git a/gui/cppcheck_fi.ts b/gui/cppcheck_fi.ts index 8372963b0..d962b2729 100644 --- a/gui/cppcheck_fi.ts +++ b/gui/cppcheck_fi.ts @@ -143,15 +143,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck - + Standard Vakio @@ -161,207 +161,217 @@ kate -l(line) (file) &Tiedosto - + &View &Näytä - + &Toolbars - + &Check &Tarkista - + &Edit &Muokkaa - + &License... &Lisenssi... - + A&uthors... &Tekijät... - + &About... &Tietoa ohjelmasta Cppcheck... - + &Files... &Tiedostot... - + Ctrl+F Ctrl+F - + &Directory... &Hakemisto... - + Ctrl+D Ctrl+D - + &Recheck files Tarkista tiedostot &uudelleen - + Ctrl+R Ctrl+R - + &Stop &Pysäytä - + Esc Esc - + &Save results to file... &Tallenna tulokset tiedostoon... - + Ctrl+S Ctrl+S - + &Quit &Lopeta - + &Clear results &Tyhjennä tulokset - + &Preferences &Asetukset - + Show style errors Näytä tyylivirheet - + Show common errors Näytä yleiset virheet - + &Check all &Valitse kaikki - + &Uncheck all &Poista kaikista valinta - + Collapse &all &Pienennä kaikki - + &Expand all &Laajenna kaikki - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + &Language &Kieli - + &Help &Ohje - + Select files to check Valitse tarkistettavat tiedostot - + Select directory to check Valitse tarkistettava hakemisto - + No suitable files found to check! Tarkistettavaksi sopivia tiedostoja ei löytynyt! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. @@ -370,47 +380,48 @@ Stop the checking before exiting. Lopeta tarkistus ennen ohjelman sammuttamista. - + License Lisenssi - + Authors Tekijät - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML-tiedostot (*.xml);;Tekstitiedostot (*.txt);;CSV-tiedostot (*.csv) - + Save the report file Tallenna raportti - + + XML files (*.xml) XML-tiedostot (*xml) - + Text files (*.txt) Tekstitiedostot (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -484,62 +495,67 @@ Lopeta tarkistus ennen ohjelman sammuttamista. ResultsTree - - + + File Tiedosto - - + + Severity Tyyppi - - + + Line Rivi - - + + Message Virhe - + Undefined file Määrittelemätön tiedosto - + Copy filename Kopioi tiedostonimi - + Copy full path Kopioi tiedoston koko polku - + Copy message - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Voit asetuksista määritellä muita ohjelmia joilla avata tämän virheen sisältävän tiedoston. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. @@ -548,12 +564,24 @@ Please check the application path and parameters are correct. Tarkista että ohjelman polku ja parametrit ovat oikeat. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style Tyyli - + error Yleinen @@ -561,31 +589,37 @@ Tarkista että ohjelman polku ja parametrit ovat oikeat. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Virheitä ei löytynyt. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Virheitä löytyi, mutta asetuksissa kyseiset virheet on määritelty piilotettavaksi. Määrittääksesi minkä tyyppisiä virheitä näytetään, avaa näkymä valikko. - + + + Failed to read the report. + + + + No errors found, nothing to save. Virheitä ei löytynyt, ei mitään tallennettavaa. - - + + Failed to save the report. Raportin tallentaminen epäonnistui. diff --git a/gui/cppcheck_nl.ts b/gui/cppcheck_nl.ts index 8df9e9757..d52970c59 100644 --- a/gui/cppcheck_nl.ts +++ b/gui/cppcheck_nl.ts @@ -141,15 +141,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck - + Standard Standaard @@ -159,207 +159,217 @@ kate -l(line) (file) &Bestand - + &View &Weergave - + &Toolbars - + &Check &Controleer - + &Edit Be&werken - + &License... &Licentie... - + A&uthors... A&uteurs... - + &About... &Over... - + &Files... &Bestanden... - + Ctrl+F Ctrl+F - + &Directory... &Mappen... - + Ctrl+D Ctrl+D - + &Recheck files &Opnieuw controleren - + Ctrl+R Ctrl+R - + &Stop &Stop - + Esc Esc - + &Save results to file... &Resultaten opslaan... - + Ctrl+S Ctrl+S - + &Quit &Afsluiten - + &Clear results &Resultaten wissen - + &Preferences &Voorkeuren - + Show style errors Toon stijl fouten - + Show common errors Toon gewone fouten - + &Check all &Selecteer alles - + &Uncheck all Selecteer &niets - + Collapse &all Alles Inkl&appen - + &Expand all Alles &Uitklappen - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + &Language &Taal - + &Help &Help - + Select files to check Selecteer bestanden om te controleren - + Select directory to check Selecteer een map om te controleren - + No suitable files found to check! Geen geschikte bestanden gevonden om te controleren! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. @@ -368,47 +378,48 @@ Stop the checking before exiting. Stop de controle alvorens te sluiten. - + License Licentie - + Authors Auteurs - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML bestanden (*.xml);;Tekst bestanden (*.txt);;CSV bestanden (*.csv) - + Save the report file Rapport opslaan - + + XML files (*.xml) XML bestanden (*.xml) - + Text files (*.txt) Tekst bestanden (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -480,62 +491,67 @@ Stop de controle alvorens te sluiten. ResultsTree - - + + File Bestand - - + + Severity Ernst - - + + Line Regel - - + + Message Boodschap - + Undefined file Niet gedefinieerd bestand - + Copy filename Kopier bestandsnaam - + Copy full path Kopieer volledig pad - + Copy message - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. U dient een applicatie te configureren in de instellingen om deze fout in te openen. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. @@ -544,12 +560,24 @@ Please check the application path and parameters are correct. Gelieve te controleren of de het pad en de parameters correct zijn. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style Stijlfouten - + error Fouten @@ -557,31 +585,37 @@ Gelieve te controleren of de het pad en de parameters correct zijn. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Geen fouten gevonden. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Fouten werden gevonden, maar volgens de configuratie zijn deze verborgen. Gebruik het uitzicht menu om te selecteren welke fouten getoond worden. - + + + Failed to read the report. + + + + No errors found, nothing to save. Geen fouten gevonden; geen data om op te slaan. - - + + Failed to save the report. Kon het rapport niet opslaan. diff --git a/gui/cppcheck_pl.ts b/gui/cppcheck_pl.ts index eac3a7b95..49c8a7820 100644 --- a/gui/cppcheck_pl.ts +++ b/gui/cppcheck_pl.ts @@ -128,10 +128,10 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck @@ -141,259 +141,270 @@ kate -l(line) (file) - + &View - + &Toolbars - + &Language - + &Help - + &Check - + &Edit - + Standard - + &License... - + A&uthors... - + &About... - + &Files... - + Ctrl+F - + &Directory... - + Ctrl+D - + &Recheck files - + Ctrl+R - + &Stop - + Esc - + &Save results to file... - + Ctrl+S - + &Quit - + &Clear results - + &Preferences - + Show style errors - + Show common errors - + &Check all - + &Uncheck all - + Collapse &all - + &Expand all - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + No suitable files found to check! - + Select files to check - + Select directory to check - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. - + License - + Authors - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + + XML files (*.xml) - + Text files (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 - + Failed to change the language: %1 @@ -458,73 +469,90 @@ Stop the checking before exiting. ResultsTree - - + + File - - + + Severity - - + + Line - - + + Message - + Undefined file - + Copy filename - + Copy full path - + Copy message - + Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style - + error @@ -532,30 +560,36 @@ Please check the application path and parameters are correct. ResultsView - - + + Cppcheck - + No errors found. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + + Failed to read the report. + + + + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_ru.ts b/gui/cppcheck_ru.ts index 4e2086f00..73a38de0d 100644 --- a/gui/cppcheck_ru.ts +++ b/gui/cppcheck_ru.ts @@ -131,15 +131,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck - + Standard @@ -149,254 +149,265 @@ kate -l(line) (file) Файл - + &View Вид - + &Toolbars - + &Check Проверить - + &Edit Правка - + &License... Лицензия... - + A&uthors... Авторы... - + &About... О программе... - + &Files... Файлы... - + Ctrl+F Ctrl+F - + &Directory... Каталог... - + Ctrl+D Ctrl+D - + &Recheck files - + Ctrl+R Ctrl+R - + &Stop Остановить - + Esc Esc - + &Save results to file... Сохранить отчёт в файл... - + Ctrl+S Ctrl+S - + &Quit Выход - + &Clear results Очистить отчёт - + &Preferences Параметры - + Show style errors Показывать ошибки стиля - + Show common errors Показывать общие ошибки - + &Check all Отметить все - + &Uncheck all Сбросить все - + Collapse &all Свернуть все - + &Expand all Развернуть все - + &Standard - + Standard items - + Toolbar - + &Categories - + Error categories - + + &Open XML... + + + + &Contents - + Categories - + Open the help contents - + F1 - + &Language Язык - + &Help Помощь - + Select files to check Выберите файлы для проверки - + Select directory to check Выберите каталог для проверки - + No suitable files found to check! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. - + License Лицензия - + Authors Авторы - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) - + Save the report file - + + XML files (*.xml) - + Text files (*.txt) Текстовые файлы (*.txt) - + CSV files (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -470,74 +481,91 @@ Stop the checking before exiting. ResultsTree - - + + File Файл - - + + Severity Важность - - + + Line Строка - - + + Message Сообщение - + Undefined file - + Copy filename Скопировать имя файла - + Copy full path Скопировать полный путь - + Copy message - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style - + error @@ -545,30 +573,36 @@ Please check the application path and parameters are correct. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Ошибок не найдено. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. - + + + Failed to read the report. + + + + No errors found, nothing to save. - - + + Failed to save the report. diff --git a/gui/cppcheck_se.ts b/gui/cppcheck_se.ts index 40fe4cb7e..3a19447e8 100644 --- a/gui/cppcheck_se.ts +++ b/gui/cppcheck_se.ts @@ -141,15 +141,15 @@ kate -l(line) (file) MainWindow - - - - + + + + Cppcheck Cppcheck - + Standard Standard @@ -159,255 +159,266 @@ kate -l(line) (file) &Arkiv - + &View &Visa - + &Toolbars Verktygsfält - + &Check &Check - + &Edit &Redigera - + &License... &Licens... - + A&uthors... &Utvecklat av... - + &About... &Om... - + &Files... &Filer... - + Ctrl+F Ctrl+F - + &Directory... &Katalog... - + Ctrl+D Ctrl+D - + &Recheck files Starta &om check - + Ctrl+R Ctrl+R - + &Stop &Stoppa - + Esc Esc - + &Save results to file... &Spara resultat till fil... - + Ctrl+S Ctrl+S - + &Quit &Avsluta - + &Clear results &Töm resultat - + &Preferences &Inställningar - + Show style errors Visa stilvarningar - + Show common errors Visa vanliga fel - + &Check all &Kryssa alla - + &Uncheck all Kryssa &ur alla - + Collapse &all Ingen bra översättning! &Fäll ihop alla - + &Expand all &Expandera alla - + &Standard &Standard - + Standard items Standard poster - + Toolbar Verktygsfält - + &Categories &Kategorier - + Error categories Fel kategorier - + + &Open XML... + + + + &Contents &Innehåll - + Categories Kategorier - + Open the help contents Öppna hjälp - + F1 F1 - + &Language &Språk - + &Help &Hjälp - + Select files to check Välj filer att kontrollera - + Select directory to check Välj katalog som skall kontrolleras - + No suitable files found to check! Inga lämpliga filer hittades! - + + Open the report file + + + + Cannot exit while checking. Stop the checking before exiting. Kan ej avsluta medans check pågår. - + License Licens - + Authors Utvecklare - + XML files (*.xml);;Text files (*.txt);;CSV files (*.csv) XML filer (*.xml);;Text filer (*.txt);;CSV filer (*.csv) - + Save the report file Spara rapport - + + XML files (*.xml) XML filer (*.xml) - + Text files (*.txt) Text filer (*.txt) - + CSV files (*.csv) CSV filer (*.csv) - + Cppcheck - %1 Cppcheck - %1 - + Failed to change the language: %1 @@ -481,62 +492,67 @@ Stop the checking before exiting. ResultsTree - - + + File Fil - - + + Severity Typ - - + + Line Rad - - + + Message Meddelande - + Undefined file Odefinierad fil - + Copy filename Kopiera filnamn - + Copy full path Kopiera full sökväg - + Copy message Kopiera meddelande - + Cppcheck Cppcheck - + Configure the text file viewer program in Cppcheck preferences/Applications. You can open this error by specifying applications in program's settings. Konfigurera program i inställningar/program. - + + Could not find the file! + + + + Could not start %1 Please check the application path and parameters are correct. @@ -545,12 +561,24 @@ Please check the application path and parameters are correct. Kontrollera att sökvägen och parametrarna är korrekta. - + + Could not find file: +%1 +Please select the directory where file is located. + + + + + Select Directory + + + + style stil - + error fel @@ -558,31 +586,37 @@ Kontrollera att sökvägen och parametrarna är korrekta. ResultsView - - + + Cppcheck Cppcheck - + No errors found. Inga fel hittades. - + Errors were found, but they are configured to be hidden. To toggle what kind of errors are shown, open view menu. Fel hittades, men de visas ej. För att ställa in vilka fel som skall visas använd visa menyn. - + + + Failed to read the report. + + + + No errors found, nothing to save. Inga fel hittades, ingenting att spara. - - + + Failed to save the report. Misslyckades med att spara rapporten.