MISRAC2012-Rule-21.7
Synopsis
(Required) The atof, atoi, atol and atoll functions of stdlib.h shall not be used
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
Uses of atof, atoi, atol, and atoll were found. This check is identical to MISRAC2004-20.10, MISRAC++2008-18-0-2, MISRAC++2023-21.2.1.
Coding standards
- CERT INT06-C
Use strtol() or a related function to convert a string token to an integer
- MISRA C:2004 20.10
(Required) The functions atof, atoi, and atol from the library stdlib.h shall not be used.
- MISRA C++ 2008 18-0-2
(Required) The library functions atof, atoi and atol from library <cstdlib> shall not be used.
- MISRA C++ 2023 21.2.1
(Required) The library functions atof, atoi, atol and atoll from <cstdlib> shall not be used
Code examples
The following code example fails the check and will give a warning:
#include <stdlib.h>
int example(char buf[]) {
return atoi(buf);
}
The following code example passes the check and will not give a warning about this issue:
void example(void) {
}