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 guideline recommendation ERR02-C. Avoid in-band error indicators.)
...
This noncompliant code example, however, does comply with guideline rule ERR30-C. Set errno to zero before calling a library function known to set errno, and check errno only after the function returns a value indicating failure.
...