Miscellaneous-NoDiscardedReturnCode¶
Do not ignore return values of functions
Required inputs: IR
This rule checks that integer return values are used and not ignored.
To discard a return value, cast the result of the function call to void.
Example
// Propagate error:
if (fseek(f, 0, SEEK_SET) != 0)
{
return ERR_CANNOT_SEEK;
}
// Ignore errors when closing the file:
(void)fclose(f);
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
discarded_return |
Return value of function discarded. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
error_types¶
error_types : set[bauhaus.analysis.config.ShortTypeName] = set()
inspect_template_instances¶
inspect_template_instances : bool = False
whitelist¶
whitelist
Dictionary of header globbing to (list of) function names whose return codes can be ignored.Type: dict[bauhaus.analysis.config.FileGlobPattern, list[bauhaus.analysis.config.GlobPattern]]
Default:
{ 'setjmp.h': ['setjmp', 'longjmp'], 'signal.h': ['signal', 'raise'], 'stdio.h': ['printf'], 'string.h': ['str[!n]*'], 'time.*': ['*'] }