The value of errno shall be set to zero prior to a call to an
errno-setting-function
The value of errno shall be set to zero prior to a
call to an errno-setting-function.
This rule comes from MISRA C®: 2012 Amendment 1.
If an error occurs during a call to an errno-setting-function,
the function writes a nonzero value to errno. Otherwise,
errno is not modified.
If you do not explicitly set errno to zero before a function
call, it can contain values from a previous call. Checking errno
for nonzero values after the function call can give the false impression that an
error occurred.
Errno-setting functions include:
ftell, fgetpos,
fgetwc and related functions.
strtoimax, strtol and related
functions.
The wide-character equivalents such as wcstoimax
and wcstol are also covered.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Resources |
| Category: Required |
| AGC Category: Required |