manual: refactorings

This commit is contained in:
Daniel Marjamäki 2009-11-16 18:01:47 +01:00
parent 40f2265abf
commit 7126524afc
1 changed files with 15 additions and 20 deletions

View File

@ -5,14 +5,14 @@
<bookinfo>
<title>Cppcheck</title>
<date>2009-11-14</date>
<date>2009-11-16</date>
</bookinfo>
<chapter>
<title>Introduction</title>
<para>Cppcheck is an analysis tool for C/C++ code. Unlike C/C++ compilers
and many other analysis tools, we don't detect syntax errors. Cppcheck
and many other analysis tools, it doesn't detect syntax errors. Cppcheck
only detects the types of bugs that the compilers normally fail to detect.
The goal is no false positives.</para>
@ -25,7 +25,7 @@
</listitem>
<listitem>
<para>Cppcheck is supposed to be compilable by any C++ compiler which
<para>Cppcheck is supposed to be compilable by any C++ compiler that
handles the latest C++ standard.</para>
</listitem>
@ -84,12 +84,8 @@ Checking path/file2.cpp...
<para>By default, an error is only reported when
<literal><literal>Cppcheck</literal></literal> is sure there is an
error.</para>
<para>When a likely issue is discovered <literal>Cppcheck</literal>
bails out without reporting this issue - to prevent false positives.
When <literal>--all</literal> is given, these issues are
reported.</para>
error. When <literal>--all</literal> is given issues will also be
reported when <literal>Cppcheck</literal> is unsure.</para>
<para>The <literal>--all</literal> flag is useful but makes
<literal>Cppcheck</literal> more unreliable, you will probably get false
@ -143,9 +139,8 @@ Checking path/file2.cpp...
<section>
<title>Saving results in file</title>
<para>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 normal shell redirections to save to
<para>Many times you will want to save the results in a file. You can
use the normal shell redirection for piping error output to a
file.</para>
<programlisting>cppcheck file1.c 2&gt; err.txt</programlisting>
@ -164,9 +159,7 @@ Checking path/file2.cpp...
<section>
<title>Multithreaded checking</title>
<para>If you have a multicore processor, it is a good idea to use the
<literal>-j</literal> flag. To use 4 threads to check the files in a
folder:</para>
<para>To use 4 threads to check the files in a folder:</para>
<programlisting>cppcheck -j 4 path</programlisting>
</section>
@ -185,7 +178,8 @@ Checking path/file2.cpp...
<programlisting>&lt;?xml version="1.0"?&gt;
&lt;results&gt;
&lt;error file="file1.cpp" line="123" id="someError" severity="error" msg="some error text"/&gt;
&lt;error file="file1.cpp" line="123" id="someError"
severity="error" msg="some error text"/&gt;
&lt;/results&gt;</programlisting>
<para>Attributes:</para>
@ -278,7 +272,7 @@ gui/test.cpp,16,error,mismatchAllocDealloc,Mismatching allocation and deallocati
<title>Suppressions</title>
<para>If you want to filter out certain errors you can suppress these.
First you need to create a suppressions file.</para>
First you need to create a suppressions file. The format is:</para>
<programlisting>[error id]:[filename]
[error id]:[filename2]
@ -344,7 +338,7 @@ QPushButton</programlisting>
<para>Then execute cppcheck with the <literal>--auto-dealloc</literal>
option:</para>
<programlisting>cppcheck --auto-dealloc qt.lst file1.cpp</programlisting>
<programlisting>cppcheck --auto-dealloc qt.lst --all file1.cpp</programlisting>
</section>
<section>
@ -399,7 +393,7 @@ void DestroyFred(void *p)
<title>Exception safety</title>
<para>Cppcheck has a few checks that ensure that you don't break the basic
guarantee of exception safety. We don't have any checks for the strong
guarantee of exception safety. It doesn't have any checks for the strong
guarantee yet.</para>
<para>Example:</para>
@ -441,6 +435,7 @@ int a(int sz)
<para>The output from Cppcheck is:</para>
<programlisting>[except2.cpp:7]: (error) Throwing exception in invalid state, p points at deallocated memory</programlisting>
<programlisting>[except2.cpp:7]: (error) Throwing exception in invalid state, p points
at deallocated memory</programlisting>
</chapter>
</book>