2323 <section >
2424 <title >Introduction</title >
2525
26- <para >This article contains an overview of how Cppcheck works.</para >
26+ <para >The goal with this article is to give users an idea of how Cppcheck
27+ works.</para >
2728
28- <para >The primary goal is that Cppcheck won't write any false warnings.
29- This means that when an error is reported there must definitely be a bug
30- in the code .</para >
29+ <para >Cppcheck is a static analysis tool that tries to completely avoid
30+ false warnings. A false warning is when the tool reports that there is an
31+ error even though there is no error .</para >
3132
32- <para >The secondary goal is to detect as many bugs as possible.</para >
33+ <para >Cppcheck is a relatively simple tool. I hope that this article will
34+ highlight that it is possible to avoid false warnings with simple
35+ analysis.</para >
3336 </section >
3437
3538 <section >
@@ -48,15 +51,38 @@ int days(int hours)
4851 therefore he could see that "23" is wrong. A tool will probably not know
4952 that there are 24 hours in a day.</para >
5053
51- <para >A tool that tries to guarantee that all bugs are found could write a
52- warning message for every "suspicious" calculation in the program. It
53- might correctly report that "hours / 23" is wrong but incorrectly warn
54- about "hours / 24".</para >
54+ <para >A tool that tries to detect all bugs could write a warning message
55+ for every calculation in the program. Then it will correctly report that
56+ "hours / 23" is wrong but incorrectly warn about "hours / 24".</para >
5557
5658 <para >Cppcheck will only write a warning message if it can determine that
5759 the calculation is wrong. In this case, no error will be written.</para >
5860 </section >
5961
62+ <section >
63+ <title >Control flow analysis</title >
64+
65+ <para >Control flow analysis is when the tool tries to determine if certain
66+ execution paths are possible.</para >
67+
68+ <programlisting >void f(int x)
69+ {
70+ if (x == 1)
71+ f1();
72+ if (x & 2)
73+ f2();
74+ }</programlisting >
75+
76+ <para >The function has 3 possible execution paths. The analysis you do in
77+ your head when you determine that there are 3 possible execution paths is
78+ "control flow analysis".</para >
79+
80+ <para >When you review code you will probably use "control flow analysis"
81+ in your head to determine if there are bugs or not.</para >
82+
83+ <para >The control flow analysis in Cppcheck is quite simple.</para >
84+ </section >
85+
6086 <section >
6187 <title >Buffer overflows</title >
6288
0 commit comments