mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
[CPP-434] Change list items to ordinary paragraphs in the Recommendation section.
This commit is contained in:
@@ -22,34 +22,35 @@ categories: (1) rewrite the signed expression so that overflow cannot occur
|
||||
but the signedness remains, or (2) rewrite (or cast) the signed expression
|
||||
into unsigned form.
|
||||
|
||||
The bullet list below lists various expressions where signed overflow may
|
||||
occur, along with proposed rewritings. It should not be
|
||||
Below we list examples of expressions where signed overflow may
|
||||
occur, along with proposed solutions. The list should not be
|
||||
considered exhaustive.
|
||||
</p>
|
||||
|
||||
<li>Given <code>unsigned short i, delta</code> and <code>i + delta < i</code>,
|
||||
<p>
|
||||
Given <code>unsigned short i, delta</code> and <code>i + delta < i</code>,
|
||||
it is possible to rewrite it as <code>(unsigned short)(i + delta) < i</code>.
|
||||
Note that <code>i + delta</code>does not actually overflow, due to <code>int</code> promotion</li>
|
||||
Note that <code>i + delta</code>does not actually overflow, due to <code>int</code> promotion
|
||||
|
||||
<li>Given <code>unsigned short i, delta</code> and <code>i + delta < i</code>,
|
||||
Given <code>unsigned short i, delta</code> and <code>i + delta < i</code>,
|
||||
it is also possible to rewrite it as <code>USHORT_MAX - delta</code>. It must be true
|
||||
that <code>delta > 0</code> and the <code>limits.h</code> or <code>climits</code>
|
||||
header has been included.</li>
|
||||
header has been included.
|
||||
|
||||
<li>Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
it is possible to rewrite it as <code>INT_MAX - delta</code>. It must be true
|
||||
that <code>delta > 0</code> and the <code>limits.h</code> or <code>climits</code>
|
||||
header has been included.</li>
|
||||
header has been included.
|
||||
|
||||
<li>Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
it is also possible to rewrite it as <code>(unsigned)i + delta < i</code>.
|
||||
Note that program semantics are affected by this change.</li>
|
||||
Note that program semantics are affected by this change.
|
||||
|
||||
<li>Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
Given <code>int i, delta</code> and <code>i + delta < i</code>,
|
||||
it is also possible to rewrite it as <code>unsigned int i, delta</code> and
|
||||
<code>i + delta < i</code>. Note that program semantics are
|
||||
affected by this change.</li>
|
||||
|
||||
affected by this change.
|
||||
</p>
|
||||
</recommendation>
|
||||
|
||||
<example>
|
||||
|
||||
Reference in New Issue
Block a user