errno not reset before calling a function
that sets errno
This defect occurs when
you do not reset errno before calling a function
that sets errno to indicate error conditions. However,
you check errno for those error conditions after
the function call.
The errno is not clean and can contain values
from a previous call. Checking errno for errors
can give the false impression that an error occurred.
errno is set to zero at program startup but
subsequently, errno is not reset by a C standard
library function. You must explicitly set errno to
zero when required.
Before calling a function that sets errno to
indicate error conditions, reset errno to zero
explicitly.
| Group: Programming |
| Language: C | C++ |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax: MISSING_ERRNO_RESET |
| Impact: High |
| CWE ID: 253, 456, 703 |
Errno not
checked | Find
defects (-checkers) | Misuse of
errno | Returned
value of a sensitive function not checked