...
| Code Block | ||||
|---|---|---|---|---|
| ||||
long num_long;
if (scanf("%ld", &num_long) != 1) {
/* handleHandle error */
}
|
In general, do not use scanf() to parse integers or floating-point numbers from input strings because the input could contain numbers not representable by the argument type.
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
long num_long;
errno = 0;
if (scanf("%ld", &num_long) != 1) {
/* handleHandle error */
}
else if (ERANGE == errno) {
if (puts("number out of range\n") == EOF) {
/* Handle error */
}
}
|
...
Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
|
| Can detect violations of this recommendation. In particular, it notes uses of the | |||||||
5.0 |
| Can detect violations of this recommendation with the CERT C Rule Pack | |||||||
| PRQA QA-C |
| Warncall for scanf etc | Fully implemented |
...