MISRA C:2023 Rule 17.7
The value returned by a function having non-void return type shall be used
Since R2024a
Description
Rule Definition
The value returned by a function having non-void return type shall be used1 .
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 R2024a
See Also
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace® Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.