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 guideline recommendation 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.
...
This recommendation encompasses guidelines rule MEM32-C. Detect and handle memory allocation errors, recommendation FIO04-C. Detect and handle input and output errors, and rule FIO34-C. Use int to capture the return value of character IO functions.
...
This compliant solution checks to make sure no output error occurred. (See guideline recommendation FIO04-C. Detect and handle input and output errors.)
...
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 the "compliant solution (Remove Existing Destination File)" under "Portable Behavior" section in guideline recommendation FIO10-C. Take care when using the rename() function.
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
CERT C++ Secure Coding Standard: EXP12-CPP. Do not ignore values returned by functions or methods
Java The CERT Oracle Secure Coding Standard for Java: EXP00-J. Do not ignore values returned by methods
Bibliography
unmigrated-wiki-markup
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.8.3, "Expression and null statements" \[[
ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] TR 24772 "CSJ Passing Parameters and Return Values" \[[MITRE|AA. Bibliography#MITRE]\] [CWE ID 754|http://cwe.mitre.org/data/definitions/754.html], "Improper Check for Unusual or Exceptional Conditions"
MITRE CWE: CWE-754, "Improper Check for Unusual or Exceptional Conditions"
Bibliography
...
EXP11-C. Do not apply operators expecting one type to data of an incompatible type 03. Expressions (EXP)