Skip to content

Commit 68a5078

Browse files
authored
Merge pull request #1741 from ivangalkin/cppcheck188
Adjust cppcheck rules with the cppcheck 1.88
2 parents db92998 + 209ba21 commit 68a5078

File tree

1 file changed

+28
-39
lines changed

1 file changed

+28
-39
lines changed

cxx-sensors/src/main/resources/cppcheck.xml

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -319,22 +319,15 @@ Buffer overrun possible for long command line arguments.
319319
</rule>
320320
<rule>
321321
<key>pointerOutOfBounds</key>
322-
<name>Undefined behaviour, pointer arithmetic 'expr' or index is out of bounds</name>
322+
<name>Pointer arithmetic overflow</name>
323323
<description>
324324
<![CDATA[
325325
<p>
326-
Undefined behaviour, pointer arithmetic '' is out of bounds. From
327-
chapter 6.5.6 in the C specification:
328-
<cite>"When an expression that has
329-
integer type is added to or subtracted from a pointer, .."</cite> and then
330-
<cite>"If both the pointer operand and the result point to elements of the
331-
same array object, or one past the last element of the array object,
332-
the evaluation shall not produce an overflow; otherwise, the behavior
333-
is undefined."</cite>
326+
Pointer arithmetic overflow.
334327
</p>
335328
<h2>References</h2>
336-
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: Indicator of Poor Code Quality</a></p>
337-
]]>
329+
<p><a href="https://cwe.mitre.org/data/definitions/758.html" target="_blank">CWE-758: Reliance on Undefined, Unspecified, or Implementation-Defined Behavior</a></p>
330+
]]>
338331
</description>
339332
<tag>cwe</tag>
340333
<tag>bug</tag>
@@ -2135,7 +2128,7 @@ string literal.
21352128
<p>
21362129
Calling sizeof for 'sizeof looks like a suspicious code and most
21372130
likely there should be just one 'sizeof'. The current code is
2138-
equivalent to 'sizeof(T)'
2131+
equivalent to 'sizeof(size_t)'
21392132
</p>
21402133
<h2>References</h2>
21412134
<p><a href="https://cwe.mitre.org/data/definitions/682.html" target="_blank">CWE-682: Incorrect Calculation</a></p>
@@ -2355,16 +2348,11 @@ The code <code>a+b?c:d</code> should be written as either <code>(a+b)?c:d</code>
23552348
<key>clarifyCondition</key>
23562349
<name>Suspicious condition (assignment + comparison)</name>
23572350
<description>
2358-
<![CDATA[
2359-
<ul>
2360-
<li>Suspicious condition (assignment + comparison), it can be clarified with parentheses.</li>
2361-
<li>Suspicious expression. Boolean result is used in bitwise operation. The operator '!'
2362-
and the comparison operators have higher precedence than bitwise operators.
2363-
It is recommended that the expression is clarified with parentheses.</li>
2364-
<li>Suspicious condition (bitwise operator + comparison).
2365-
Comparison operators have higher precedence than bitwise operators.
2366-
Please clarify the condition with parentheses.</li>
2367-
</ul>
2351+
<![CDATA[
2352+
<p>
2353+
Suspicious condition (assignment + comparison); Clarify expression
2354+
with parentheses.
2355+
</p>
23682356
<h2>References</h2>
23692357
<p><a href="https://cwe.mitre.org/data/definitions/398.html" target="_blank">CWE-398: Indicator of Poor Code Quality</a></p>
23702358
]]>
@@ -2717,15 +2705,15 @@ not properly checked.
27172705
</rule>
27182706
<rule>
27192707
<key>stlIfStrFind</key>
2720-
<name>Inefficient usage of string::find() in condition; string::compare() would be faster</name>
2708+
<name>Inefficient usage of string::find() in condition; string::starts_with() would be faster</name>
27212709
<description>
27222710
<![CDATA[
27232711
<p>
2724-
Either inefficient or wrong usage of string::find(). string::compare()
2725-
will be faster if string::find's result is compared with 0, because it
2726-
will not scan the whole string. If your intention is to check that
2727-
there are no findings in the string, you should compare with
2728-
std::string::npos.
2712+
Either inefficient or wrong usage of string::find().
2713+
string::starts_with() will be faster if string::find's result is
2714+
compared with 0, because it will not scan the whole string. If your
2715+
intention is to check that there are no findings in the string, you
2716+
should compare with std::string::npos.
27292717
</p>
27302718
<h2>References</h2>
27312719
<p><a href="https://cwe.mitre.org/data/definitions/597.html" target="_blank">CWE-597: Use of Wrong Operator in String Comparison</a></p>
@@ -3305,7 +3293,7 @@ invalid.
33053293
<![CDATA[
33063294
<p>
33073295
BOOST_FOREACH caches the end() iterator. It's undefined behavior if
3308-
you modify the container inside.
3296+
you modify the container inside.
33093297
</p>
33103298
<h2>References</h2>
33113299
<p><a href="https://cwe.mitre.org/data/definitions/664.html" target="_blank">CWE-664: Improper Control of a Resource Through its Lifetime</a></p>
@@ -4264,9 +4252,11 @@ meaningless. Did you intend to write '(*A)++;'?
42644252
</rule>
42654253
<rule>
42664254
<key>comparisonOfBoolWithInvalidComparator</key>
4267-
<name>Comparison of a boolean value using relational (&lt;, &gt;, &lt;= or &gt;=) operator</name>
4255+
<name>Comparison of a boolean value using relational operator (&lt;, &gt;, &lt;= or &gt;=)</name>
42684256
<description>
4269-
Comparison of a boolean value using relational (&lt;, &gt;, &lt;= or &gt;=) operator.
4257+
<![CDATA[
4258+
The result of the expression 'expression' is of type 'bool'. Comparing 'bool' value using relational (&lt;, &gt;, &lt;= or &gt;=) operator could cause unexpected results.
4259+
]]>
42704260
</description>
42714261
<internalKey>comparisonOfBoolWithInvalidComparator</internalKey>
42724262
<severity>MINOR</severity>
@@ -4306,7 +4296,7 @@ unnamed namespace.
43064296
<description>
43074297
<![CDATA[
43084298
<p>
4309-
The array 'buffer' is filled incompletely. The function 'function()'
4299+
The array 'buffer' is filled incompletely. The function 'memset()'
43104300
needs the size given in bytes, but an element of the given array is
43114301
larger than one byte. Did you forget to multiply the size with
43124302
'sizeof(*buffer)'?
@@ -4651,7 +4641,7 @@ copy constructor instead of allocating new memory.
46514641
<name>Invalid memory address freed</name>
46524642
<description>
46534643
<![CDATA[
4654-
Invalid memory address freed.
4644+
Mismatching address is freed. The address you get from malloc() must be freed without offset.
46554645
]]>
46564646
</description>
46574647
<internalKey>invalidFree</internalKey>
@@ -5695,12 +5685,11 @@ no effect.
56955685
<description>
56965686
<![CDATA[
56975687
<p>
5698-
Array 'x[SZ]' accessed at larger index I, which is out of bounds. Otherwise
5699-
condition '==I' is redundant.
5688+
Array 'x[SZ]' accessed at larger index I, which is out of bounds.
57005689
</p>
57015690
<h2>References</h2>
5702-
<p><a href="https://cwe.mitre.org/data/definitions/119.html" target="_blank">CWE-119: Improper Restriction of Operations within the Bounds of a Memory Buffer</a></p>
5703-
]]>
5691+
<p><a href="https://cwe.mitre.org/data/definitions/788.html" target="_blank">CWE-788: Access of Memory Location After End of Buffer</a></p>
5692+
]]>
57045693
</description>
57055694
<tag>bug</tag>
57065695
<tag>cert</tag>
@@ -6632,8 +6621,8 @@ Unsafe allocation. If funcName() throws, memory could be leaked. Use
66326621
make_shared&lt;T&gt;() / make_unique&lt;T&gt;() instead.
66336622
</p>
66346623
<h2>References</h2>
6635-
<p><a href="https://cwe.mitre.org/data/definitions/401.html" target="_blank">CWE-401: Improper Release of Memory Before Removing Last Reference ('Memory Leak')</a></p>
6636-
]]>
6624+
<p><a href="https://cwe.mitre.org/data/definitions/401.html" target="_blank">CWE-401: Improper Release of Memory Before Removing Last Reference</a></p>
6625+
]]>
66376626
</description>
66386627
<tag>cwe</tag>
66396628
<internalKey>leakUnsafeArgAlloc</internalKey>

0 commit comments

Comments
 (0)