[metadata]
id = "EXP12-C"
type = "recommendation"
category = "EXP"
number = 12
title = "Do not ignore values returned by functions"
description = """
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 (seeERR02-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. Subclause 6.8.3 of the C Standard
[ISO/IEC 9899:2011] states: All expression statements, such as function calls
with an ignored value, are implicitly cast tovoid. Because a return value often
contains important information about possible errors, it should always be
checked; otherwise, the cast should be made explicit to signify programmer
intent. If a function returns no meaningful value, it should be declared with
return typevoid.
"""
severity = "Medium"
likelihood = "Unlikely"
priority = "P4"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "Aug 06, 2025"
[rules.cert_c.EXP12-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/EXP12-C.+Do+not+ignore+values+returned+by+functions"
cwe = ["CWE-754"]