MISRAC2012-Rule-22.8
In this section:
Synopsis
(Required) The value of errno shall be set to zero prior to a call to an errno-setting-function.
Enabled by default
Yes
Severity/Certainty
Medium/Medium

Full description
errno is not set to zero prior a call to an errno-setting-function.
Coding standards
- MISRA C:2012 Rule-22.8
(Required) The value of errno shall be set to zero prior to a call to an errno-setting-function
Code examples
The following code example fails the check and will give a warning:
#include<mc3_types.h>
void f ( void )
{
float64_t f64;
f64 = strtod ( "A.12", NULL );
}
The following code example passes the check and will not give a warning about this issue:
#include<mc3_types.h>
#include<errno.h>
void f ( void )
{
float64_t f64;
if ( 0 == errno )
{
f64 = strtod ( "A.12", NULL ); /* Compliant by exception */
if ( 0 == errno )
{
}
}
else
{
errno = 0;
f64 = strtod ( "A.13", NULL ); /* Compliant */
if ( 0 == errno )
{
}
}
}