Apply suggestions from code review

Co-authored-by: Ben Ahmady <32935794+subatoi@users.noreply.github.com>
This commit is contained in:
Alexander Eyers-Taylor
2023-12-11 13:48:39 +00:00
committed by Alex Eyers-Taylor
parent da5c2d9bad
commit c883ce8a5e

View File

@@ -7,11 +7,7 @@
<overview>
<p>
This query finds calls of <tt>scanf</tt>-like functions with
improper return-value checking.
</p>
<p>
Specifically, the query flags uses of <code>scanf</code> where the return value is checked
only against zero.
improper return-value checking. Specifically, it flags uses of <code>scanf</code> where the return value is only checked against zero.
</p>
<p>
Functions in the <tt>scanf</tt> family return either <tt>EOF</tt> (a negative value)
@@ -24,13 +20,12 @@ is not enough.
<recommendation>
<p>
Ensure that all uses of <tt>scanf</tt> check the return value against the expected number of arguments
rather than just against zero
rather than just against zero.
</p>
</recommendation>
<example>
<p>This example shows different ways of guarding a <tt>scanf</tt> output:
</p>
<p>The following examples show different ways of guarding a <tt>scanf</tt> output. In the BAD examples, the results are only checked against zero. In the GOOD examples, the results are checked against the expected number of matches instead.</p>
<sample src="IncorrectCheckScanf.cpp" />
</example>