Query module CheckingReturnValues

name
Unchecked return value
description
The return value of each non-void function call should be checked for error conditions, or cast to (void) if irrelevant.
kind
problem
id
cpp/jpl-c/checking-return-values
problem.severity
warning

Imports

cpp

Provides classes and predicates for working with C/C++/ObjC/ObjC++ code.

Predicates

whitelist

In its full generality, the rule applies to all functions that return non-void, including things like ‘printf’ and ‘close’, which are routinely not checked because the behavior on success is the same as the behavior on failure. The recommendation is to add an explicit cast to void for such functions. For code bases that have not been developed with this rule in mind, at least for such commonly ignored functions, it may be better to add them as exceptions to this whitelist predicate.