...
Many existing functions that return errno
are declared as returning a value of type int
. It is semantically unclear by looking at the function declaration or prototype if these functions return an error status or a value or, worse, some combination of the two. (See ERR02-C. Avoid in-band error indicators.)
TR 24731-1 introduces introduced the new type errno_t
that is defined to be type int
in errno.h
and elsewhere. Many of the functions defined in TR 24731-1 return values of this type [TR 24731-1]. The errno_t
type should be used as the type of an object that may contain only contain values that might be found in errno
. For example, a function that returns the value of errno
should be declared as having the return type errno_t
.
...
Failing to test for error conditions can lead to vulnerabilities of varying severity. Declaring functions that return an errno
with a return type of errno_t
will not eliminate this problem but may reduce errors caused by programmers' misunderstanding the purpose of a return value.
...