diff --git a/man/manual.docbook b/man/manual.docbook
index 1b7fab8db..3c2a10eb7 100644
--- a/man/manual.docbook
+++ b/man/manual.docbook
@@ -5,22 +5,22 @@
Cppcheck
- 2009-10-11
+ 2009-11-14
Introduction
Cppcheck is a static analysis tool for C/C++ code - it textually
- inspects the source code to detect bugs.
+ inspects your C/C++ source code to detect bugs.
Cppcheck detects issues that you will not find with your compiler.
But Cppcheck doesn't detect the types of bugs that compilers
detect.
It is our goal to generate no false positives. We always try to
- achieve 0 false positives. It means that there will always be issues that
- Cppcheck fail to detect.
+ achieve 0 false positives. There will always be issues that Cppcheck fail
+ to detect.
Supported platforms:
@@ -40,8 +40,6 @@
cpu and memory.
-
-
@@ -88,12 +86,30 @@ Checking path/file2.cpp...
- Uncertain errors
+ Possible errors
- By default, only certain errors are reported.
+ By default, an error is only reported when
+ Cppcheck is sure there is an
+ error.
- With "--all" you will get more reports. But beware - some messages
- may be wrong.
+ When a likely issue is discovered, Cppcheck
+ bails out without reporting this issue - to prevent false positives. But
+ with --all you can ensure that these issues are
+ reported.
+
+ The --all flag is useful but makes
+ Cppcheck more unreliable:
+
+
+
+ You will probably get false positives
+
+
+
+ Cppcheck can detect issues that it can't detect by
+ default
+
+
Here is a simple code example:
@@ -145,7 +161,8 @@ Checking path/file2.cpp...
Many times you will want to save the results in a file. The
results are written to stderr and the progress messages are written to
- stdout. So you can use the standard redirections to save to file.
+ stdout. So you can use the normal shell redirections to save to
+ file.
cppcheck file1.c 2> err.txt
@@ -216,7 +233,7 @@ Checking path/file2.cpp...
msg
- the error message in plain text
+ the error message
@@ -307,7 +324,7 @@ uninitvar
void Form1::foo()
{
- QPushButton *pb = new QPushButton( "OK", this );
+ QPushButton *pb = new QPushButton("OK", this);
}
Cppcheck can't see where the deallocation is when you have such
@@ -339,11 +356,26 @@ QPushButton
Userdefined allocation/deallocation functions
- Cppcheck understands many common allocation and deallocation
- functions. But not all.
+ Cppcheck understands many common allocation and
+ deallocation functions. But not all.
- Here is a trick to add custom checking. First we write simple
- implementations for the allocation and deallocation functions:
+ Here is example code that might leak memory or resources:
+
+ void foo(int x)
+{
+ void *f = CreateFred();
+ if (x == 1)
+ return;
+ DestroyFred(f);
+}
+
+ If you analyse that with Cppcheck it won't find any leaks:
+
+ cppcheck --all fred1.cpp
+
+ You can add some custom leaks checking by providing simple
+ implementations for the allocation and deallocation functions. Write
+ this in a separate file:
void *CreateFred()
{
@@ -358,18 +390,7 @@ void DestroyFred(void *p)
When Cppcheck see this it understands that CreateFred will return
allocated memory and that DestroyFred will deallocate memory.
- Here is an example program that uses CreateFred and
- DestroyFred:
-
- void foo(int x)
-{
- void *f = CreateFred();
- if (x == 1)
- return;
- DestroyFred(f);
-}
-
- Execute Cppcheck this way:
+ Now, execute Cppcheck this way:
cppcheck --append=fred.cpp fred1.cpp
@@ -399,11 +420,11 @@ void DestroyFred(void *p)
To enable the exception safety checking you can use
--enable:
- cppcheck --enable except.cpp
+ cppcheck --enable fred.cpp
The output will be:
- [except.cpp:3]: (style) Upon exception there is memory leak: a
+ [fred.cpp:3]: (style) Upon exception there is memory leak: a
If an exception occurs when b is allocated,
a will leak.