Enable type-checking of arguments passed to printf() et al.

This patch modifies the declarations of the functions printf() et al.
and adds the right GCC attribute to request the compiler to check
the type of the arguments passed to these functions against the given
format string. This will ensure that the compiler outputs warning
messages like the following whenever it detects an inconsistency:

 file.c:42: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long int’

It also fixes the type mismatch inconsistencies that it revealed
across the code base.

NOTE: THIS PATCH MAY FORCE PLATFORM PORTS OR SP/SPDS THAT USE THE
PRINTF FAMILY OF FUNCTIONS TO FIX ANY TYPE MISMATCH INCONSISTENCIES.

Change-Id: If36bb54ec7d6dd2cb4791d89b02a24ac13fd2df6
This commit is contained in:
Sandrine Bailleux 2015-02-05 15:42:31 +00:00
parent 5930eadbe5
commit dad25049ce
5 changed files with 25 additions and 24 deletions

View file

@ -84,6 +84,6 @@
void __dead2 do_panic(void);
#define panic() do_panic()
void tf_printf(const char *fmt, ...);
void tf_printf(const char *fmt, ...) __printflike(1, 2);
#endif /* __DEBUG_H__ */