manual: removed information about possible errors. The inconclusive checks have been disabled. Removed section about --auto-dealloc.. this section is not relevant at the moment.
This commit is contained in:
parent
2d41e31cdd
commit
af49d4ba87
|
@ -91,37 +91,6 @@ Checking path/file2.cpp...
|
||||||
2/2 files checked 100% done</programlisting>
|
2/2 files checked 100% done</programlisting>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
|
||||||
<title>Possible errors</title>
|
|
||||||
|
|
||||||
<para>By default, an error is only reported when
|
|
||||||
<literal><literal>Cppcheck</literal></literal> is sure there is an
|
|
||||||
error. When <literal>--enable=possibleError</literal> is given issues
|
|
||||||
will also be reported when <literal>Cppcheck</literal> is unsure.</para>
|
|
||||||
|
|
||||||
<para>The <literal>--enable=possibleError</literal> flag is useful but
|
|
||||||
makes <literal>Cppcheck</literal> more unreliable, you will probably get
|
|
||||||
false positives.</para>
|
|
||||||
|
|
||||||
<para>Here is a simple code example:</para>
|
|
||||||
|
|
||||||
<programlisting>void f()
|
|
||||||
{
|
|
||||||
Fred *f = new Fred;
|
|
||||||
}</programlisting>
|
|
||||||
|
|
||||||
<para>Execute this command:</para>
|
|
||||||
|
|
||||||
<programlisting>cppcheck --enable=possibleError file1.cpp</programlisting>
|
|
||||||
|
|
||||||
<para>The output from Cppcheck:</para>
|
|
||||||
|
|
||||||
<programlisting>[file1.cpp:4]: (possible error) Memory leak: fred</programlisting>
|
|
||||||
|
|
||||||
<para>The "possible" means that the reported message may be wrong (if
|
|
||||||
Fred has automatic deallocation it is not a memory leak).</para>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Stylistic issues</title>
|
<title>Stylistic issues</title>
|
||||||
|
|
||||||
|
@ -322,45 +291,7 @@ uninitvar</programlisting>
|
||||||
|
|
||||||
<para>Looking for memory leaks and resource leaks is a key feature of
|
<para>Looking for memory leaks and resource leaks is a key feature of
|
||||||
Cppcheck. Cppcheck can detect many common mistakes by default. But through
|
Cppcheck. Cppcheck can detect many common mistakes by default. But through
|
||||||
some tweaking you can both increase the capabilities and also reduce the
|
some tweaking you can improve the checking.</para>
|
||||||
amount of false positives.</para>
|
|
||||||
|
|
||||||
<section>
|
|
||||||
<title>Automatic deallocation</title>
|
|
||||||
|
|
||||||
<para>A common cause of false positives is when there is automatic
|
|
||||||
deallocation. Here is an example:</para>
|
|
||||||
|
|
||||||
<programlisting>void Form1::foo()
|
|
||||||
{
|
|
||||||
QPushButton *pb = new QPushButton("OK", this);
|
|
||||||
}</programlisting>
|
|
||||||
|
|
||||||
<para>Cppcheck can't see where the deallocation is when you have such
|
|
||||||
code.</para>
|
|
||||||
|
|
||||||
<para>If you execute:</para>
|
|
||||||
|
|
||||||
<programlisting>cppcheck --enable=possibleError file1.cpp</programlisting>
|
|
||||||
|
|
||||||
<para>The result will be:</para>
|
|
||||||
|
|
||||||
<programlisting>[file1.cpp:4]: (possible error) Memory leak: pb</programlisting>
|
|
||||||
|
|
||||||
<para>The "possible" in the error message means that the message may be
|
|
||||||
a false positive.</para>
|
|
||||||
|
|
||||||
<para>To avoid such false positives, create a textfile and write the
|
|
||||||
names of the automaticly deallocated classes.</para>
|
|
||||||
|
|
||||||
<programlisting>QLabel
|
|
||||||
QPushButton</programlisting>
|
|
||||||
|
|
||||||
<para>Then execute cppcheck with the <literal>--auto-dealloc</literal>
|
|
||||||
option:</para>
|
|
||||||
|
|
||||||
<programlisting>cppcheck --auto-dealloc qt.lst --enable=possibleError file1.cpp</programlisting>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Userdefined allocation/deallocation functions</title>
|
<title>Userdefined allocation/deallocation functions</title>
|
||||||
|
|
Loading…
Reference in New Issue