MISRA C:2012 Rule 17.7
The value returned by a function having non-void return type shall be used
Description
Rule Definition
The value returned by a function having non-void return type shall be used.
Rationale
You can unintentionally call a function with a non-void
return
type but not use the return value. Because the compiler allows the
call, you might not catch the omission. This rule forbids calls to
a non-void
function where the return value is not
used. If you do not intend to use the return value of a function,
explicitly cast the return value to void
.
Polyspace Implementation
The checker flags functions with non-void
return if the return
value is not used or not explicitly cast to a void
type.
The checker does not flag the functions memcpy
,
memset
, memmove
,
strcpy
, strncpy
, strcat
,
strncat
because these functions simply return a pointer to
their first arguments.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Function |
Category: Required |
AGC Category: Readability |
Version History
Introduced in R2014b