Many functions return useful values whether or not the function has side effects. In most cases, this value is used to signify whether the function successfully completed its task or if some error occurred. (See ERR02-C. Avoid in-band error indicators.) Other times, the value is the result of some computation and is an integral part of the function's API.
...
EXP12-EX1: If the return value is inconsequential or if any errors can be safely ignored, such as for functions called because of their side effects, the function should be explicitly cast to void
to signify programmer intent. For an example of this exception, see "Compliant Solution (Remove Existing Destination File)" under the section "Portable Behavior" in FIO10-C. Take care when using the rename() function.
EXP12-EX2: If a function cannot fail or if the return value cannot signify an error condition, the return value may be ignored. Such functions should be added to a whitelist when automatic checkers are used.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| CHECKED_RETURN | Finds inconsistencies in how function call return values are handled. Coverity Prevent cannot discover all violations of this recommendation, so further verification is necessary. | |||||||
Splint |
|
|
| ||||||
Compass/ROSE |
|
|
| ||||||
| SV.RVT.RETVAL_NOTTESTED |
| |||||||
| 382 S | Fully implemented. | |||||||
| ignrtrn | Fully implemented. |
...
ISO/IEC 9899:2011 Section 6.8.3, "Expression and null statements"
ISO/IEC TR 24772 "CSJ Passing parameters and return values"
...