From e285e950c94cea676039ae613506a395a964c0cb Mon Sep 17 00:00:00 2001 From: Tim Gerundt Date: Wed, 5 Jan 2011 03:57:16 +0100 Subject: [PATCH 01/11] Web: Add a first version of a website --- htdocs/index.php | 134 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 htdocs/index.php diff --git a/htdocs/index.php b/htdocs/index.php new file mode 100644 index 000000000..82e912109 --- /dev/null +++ b/htdocs/index.php @@ -0,0 +1,134 @@ + + + + + Cppcheck - A tool for static C/C++ code analysis + + + + +
+
+ +
+
+
+
+

Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ +compilers and many other analysis tools, it don't detect syntax errors. Cppcheck +only detects the types of bugs that the compilers normally fail to detect. The +goal is no false positives.

+ +

Download

+

You can download the standalone tool from our +project page or try it +as plugin for your favorite IDE:

+ +

No plugin exists for Visual Studio, but it's possible to add +Cppcheck as an external tool.

+ +

Features

+
    +
  • Out of bounds checking
  • +
  • Check the code for each class
  • +
  • Checking exception safety
  • +
  • Memory leaks checking
  • +
  • Warn if obsolete functions are used
  • +
  • Check for invalid usage of STL
  • +
  • Check for uninitialized variables and unused functions
  • +
+ +

Support

+
    +
  • Use Trac to report + bugs and feature requests
  • +
  • Ask questions in the forum + or at the IRC channel #cppcheck
  • +
  • For more details look at the wiki
  • +
+
+
+ + \ No newline at end of file From 70a29ccb8a5e5a40435b5c00c3755aaaa9ad21d2 Mon Sep 17 00:00:00 2001 From: Tim Gerundt Date: Thu, 6 Jan 2011 13:32:04 +0100 Subject: [PATCH 02/11] Web: Add favicon --- htdocs/favicon.ico | Bin 0 -> 5430 bytes htdocs/index.php | 1 + 2 files changed, 1 insertion(+) create mode 100644 htdocs/favicon.ico diff --git a/htdocs/favicon.ico b/htdocs/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..60bb7200129eb8d099aa04c53288bc2e3b1e893c GIT binary patch literal 5430 zcmcIo2~?EV6~42u2?GPNi68^YjuAvb4alM(Wr2rIFxF$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ETtth1ex5gTRjzmL2f9k2VlxHR~>xZK5ge8s`q`WX5+<|YCI z09&BrTF}%r63c}!k`Q`|7I(>0RFNId4i%sPsIW*&(N!U2cdvph?kY)j6^&Iu5rAbY zXpT-nddSx+PEZRV(8Duja28<{c%7gSuMNkw7&K2V0tU`_pgQ)gW6A)zLa=(&7`!L zItuds1TBex5_%_6O4LpI?F#4t9?Uyuq#n91Lw{#)4Zcgd0_?M#7ukOTaA&*J zJ{VtiXWcp}N8_x!iZ(NV$r<DU#cKlw{8zf$ zA+Lq?>U9`x4+-Z}268yZliN@qpL&#X?#RaXm-tp-t$Lo%=ckXe^DeY?BzrW>!aZJ( zvIzJ&uoK^W*T~LKNNAAf`#L*UqOBwKMP3s%rKM7yfla^U{LbHeW+ev)pD`jYGmk-D zULUlbj2vCAv9Q>M{8)~05A3Y0cEge9qdbc5+qe_2fgR?3Ra`8X2i|hEn9uvpqy_)) zai07RbtmZCZvFU{){j05oJUps9%G#%d-wj>T&*s7+1vZ{wUsM{zpE?H*Fxs|D188? zMAikR99LF&yDT0R5^_F2KE5$;*swa>b3VhF!M+gA6P`qOkx#0k(d!A=0XRLXz_kcf WCN*G-7ZP_dcyVfc^Q)<-km!HA0M+LJ literal 0 HcmV?d00001 diff --git a/htdocs/index.php b/htdocs/index.php index 82e912109..c5ea36b95 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -70,6 +70,7 @@ a:active { color:#369; text-decoration:none; } padding: .5em; } + From 9fbbb910901ba2df61b79799024efeae34a8d415 Mon Sep 17 00:00:00 2001 From: Tim Gerundt Date: Fri, 7 Jan 2011 16:04:01 +0100 Subject: [PATCH 06/11] Web: Move devinfo.html to a new place - Apache from SF.net don't like relative paths for redirecting --- htdocs/.htaccess | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/.htaccess b/htdocs/.htaccess index e65a9426b..761a0f759 100644 --- a/htdocs/.htaccess +++ b/htdocs/.htaccess @@ -1,2 +1,2 @@ #Redirect "devinfo.html" to the new place... -Redirect permanent /devinfo.html /devinfo/ \ No newline at end of file +Redirect permanent /devinfo.html http://cppcheck.sourceforge.net/devinfo/ \ No newline at end of file From dcc0f28f3415de9dbf7d50a191f9c19b99c92c7b Mon Sep 17 00:00:00 2001 From: Greg Hewgill Date: Tue, 1 Feb 2011 08:07:41 +1300 Subject: [PATCH 07/11] check that misused scope object does not pick nested class --- test/testother.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index a835ba30d..7573b9d5e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -89,6 +89,7 @@ private: TEST_CASE(testMisusedScopeObjectDoesNotPickLocalClassConstructors); TEST_CASE(testMisusedScopeObjectDoesNotPickUsedObject); TEST_CASE(testMisusedScopeObjectDoesNotPickPureC); + TEST_CASE(testMisusedScopeObjectDoesNotPickNestedClass); TEST_CASE(trac2071); TEST_CASE(trac2084); @@ -1358,6 +1359,27 @@ private: ASSERT_EQUALS("", errout.str()); } + void testMisusedScopeObjectDoesNotPickNestedClass() + { + const char code[] = "class ios_base {\n" + "public:\n" + " class Init {\n" + " public:\n" + " };\n" + "};\n" + "class foo {\n" + "public:\n" + " foo();\n" + " void Init(int);\n" + "};\n" + "foo::foo() {\n" + " Init(0);\n" + "}\n"; + + check(code, "test.cpp"); + ASSERT_EQUALS("", errout.str()); + } + void trac2084() { check("#include \n" From 250149300dd86ab6bebfea7d5d78f29dbcf4ced5 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Tue, 1 Feb 2011 08:33:02 +0200 Subject: [PATCH 08/11] Move FileLister* to CLI doxygen-module. I forgot to update the doxygen module when moving FileLister* to CLI. Also add CLI doxygen group for ThreadExecutor. --- cli/filelister.h | 2 +- cli/filelister_unix.h | 2 +- cli/filelister_win32.h | 2 +- cli/threadexecutor.h | 5 +++++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cli/filelister.h b/cli/filelister.h index be4c60016..aa292b701 100644 --- a/cli/filelister.h +++ b/cli/filelister.h @@ -22,7 +22,7 @@ #include #include -/// @addtogroup Core +/// @addtogroup CLI /// @{ /** diff --git a/cli/filelister_unix.h b/cli/filelister_unix.h index f0b4e4c96..594580f0d 100644 --- a/cli/filelister_unix.h +++ b/cli/filelister_unix.h @@ -23,7 +23,7 @@ #include #include "filelister.h" -/// @addtogroup Core +/// @addtogroup CLI /// @{ diff --git a/cli/filelister_win32.h b/cli/filelister_win32.h index 4f89438bd..1095c79d7 100644 --- a/cli/filelister_win32.h +++ b/cli/filelister_win32.h @@ -23,7 +23,7 @@ #include #include "filelister.h" -/// @addtogroup Core +/// @addtogroup CLI /// @{ diff --git a/cli/threadexecutor.h b/cli/threadexecutor.h index 44238f5e9..1fb0af877 100644 --- a/cli/threadexecutor.h +++ b/cli/threadexecutor.h @@ -25,6 +25,9 @@ #include "settings.h" #include "errorlogger.h" +/// @addtogroup CLI +/// @{ + /** * This class will take a list of filenames and settings and check then * all files using threads. @@ -95,4 +98,6 @@ private: void operator=(const ThreadExecutor &); }; +/// @} + #endif // THREADEXECUTOR_H From 2d1ccad44e52cbc679528c0dc58e068123d13a4a Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Tue, 1 Feb 2011 19:55:02 +1100 Subject: [PATCH 09/11] Turned failing ASSERT_EQUALS into TODO_ASSERT_EQUALS. --- test/testother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testother.cpp b/test/testother.cpp index 7573b9d5e..af08d80c4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1377,7 +1377,7 @@ private: "}\n"; check(code, "test.cpp"); - ASSERT_EQUALS("", errout.str()); + TODO_ASSERT_EQUALS("", "[test.cpp:13]: (error) instance of \"Init\" object destroyed immediately\n", errout.str()); } void trac2084() From 8298c07d60e2be7df17dc58b33fffd435d544ce0 Mon Sep 17 00:00:00 2001 From: Pete Johns Date: Tue, 1 Feb 2011 19:56:05 +1100 Subject: [PATCH 10/11] Astyle formatting. --- cli/filelister_win32.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/filelister_win32.cpp b/cli/filelister_win32.cpp index 041613331..776e0245a 100644 --- a/cli/filelister_win32.cpp +++ b/cli/filelister_win32.cpp @@ -88,7 +88,7 @@ static BOOL MyIsDirectory(std::string path) return (GetFileAttributes(path.c_str()) & FILE_ATTRIBUTE_DIRECTORY); #else // See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx -return PathIsDirectory(path.c_str()); + return PathIsDirectory(path.c_str()); #endif } From c2de1a8a52d21a37ee49ecf21be16abc9b3c0f09 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Mon, 31 Jan 2011 22:49:52 +0200 Subject: [PATCH 11/11] Convert "too many configurations" message to information message. The "too many configurations"-message is currently only printed to the log. So it won't be seen by users integrating Cppcheck using XML error file. It is also easily missed in the GUI as it only shows up in the checking log. Making it a information message it shows up with the other errors and tells user that file was not completely checked. Ticket #2527 (Make "too many configurations" message an error message) --- lib/cppcheck.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 62719d6c6..db0a15105 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -151,13 +151,21 @@ unsigned int CppCheck::check() // was used. if (!_settings._force && checkCount > 11) { - if (_settings._errorsOnly == false) - { - const std::string fixedpath = Path::toNativeSeparators(fname); - _errorLogger.reportOut(std::string("Bailing out from checking ") + fixedpath + - ": Too many configurations. Recheck this file with --force if you want to check them all."); - } - + const std::string fixedpath = Path::toNativeSeparators(fname); + ErrorLogger::ErrorMessage::FileLocation location; + location.setfile(fixedpath); + std::list loclist; + loclist.push_back(location); + const std::string msg("Interrupted checking because of too many #ifdef configurations.\n" + "The checking of the file was interrupted because there were too many " + "#ifdef configurations. Checking of all #ifdef configurations can be forced " + "by --force command line option or from GUI preferences. However that may " + "increase the checking time."); + ErrorLogger::ErrorMessage errmsg(loclist, + Severity::information, + msg, + "toomanyconfigs"); + _errorLogger.reportErr(errmsg); break; }