CERT-FIO47-C_a
In this section:
Synopsis
Use valid format strings.
Enabled by default
Yes
Severity/Certainty
High/Low

Full description
The formatted output functions (fprintf() and related functions) convert, format, and print their arguments under control of a format string. The C standard outlines what format specifiers are valid in a format string. This check will find cases where a format string specifier is of an invalid form.
Coding standards
- CERT FIO47-C
Use valid format strings
Code examples
The following code example fails the check and will give a warning:
#include <stdio.h>
void example(int i) {
// Invalid length and type specifier
printf("%Ld", i);
}
The following code example passes the check and will not give a warning about this issue:
#include <stdio.h>
void example(int i) {
printf("%hd", i);
}