Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 466f7fe

Browse files
committed
C++: Use <ol> for recommendations
1 parent 7d7d166 commit 466f7fe

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.qhelp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,39 @@ optimizing compiler.
1818
<recommendation>
1919
<p>
2020
Solutions to this problem can be thought of as falling into one of two
21-
categories: (1) rewrite the signed expression so that overflow cannot occur
22-
but the signedness remains, or (2) change the variables and all their uses to
23-
be unsigned. The following cases all fall into the first category.
21+
categories:
2422
</p>
2523

24+
<ol>
25+
<li>Rewrite the signed expression so that overflow cannot occur
26+
but the signedness remains.</li>
27+
<li>Change the variables and all their uses to be unsigned.</li>
28+
</ol>
29+
2630
<p>
31+
The following cases all fall into the first category.
32+
</p>
33+
34+
<ol>
35+
<li>
2736
Given <code>unsigned short n1, delta</code> and <code>n1 + delta &lt; n1</code>,
2837
it is possible to rewrite it as <code>(unsigned short)(n1 + delta)&nbsp;&lt;&nbsp;n1</code>.
2938
Note that <code>n1 + delta</code> does not actually overflow, due to <code>int</code> promotion.
30-
</p>
39+
</li>
3140

32-
<p>
41+
<li>
3342
Given <code>unsigned short n1, delta</code> and <code>n1 + delta &lt; n1</code>,
3443
it is also possible to rewrite it as <code>n1 &gt; USHORT_MAX - delta</code>. The
3544
<code>limits.h</code> or <code>climits</code> header must then be included.
36-
</p>
45+
</li>
3746

38-
<p>
47+
<li>
3948
Given <code>int n1, delta</code> and <code>n1 + delta &lt; n1</code>,
4049
it is possible to rewrite it as <code>n1 &gt; INT_MAX - delta</code>. It must be true
4150
that <code>delta &gt;= 0</code> and the <code>limits.h</code> or <code>climits</code>
4251
header has been included.
43-
</p>
52+
</li>
53+
</ol>
4454
</recommendation>
4555

4656
<example>

0 commit comments

Comments
 (0)