aboutsummaryrefslogtreecommitdiffstats
path: root/include/stdlib
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2015-02-05 15:42:31 +0000
committerSandrine Bailleux <sandrine.bailleux@arm.com>2015-03-06 13:07:43 +0000
commitdad25049cec0e30ca9771e435064ebf853d97bba (patch)
tree9c4a067d102cb11939d662c93c521b897ba8cbf7 /include/stdlib
parent5930eadbe5d8d4c3f15fd910476f72cd5bf86f44 (diff)
downloadplatform_external_arm-trusted-firmware-dad25049cec0e30ca9771e435064ebf853d97bba.tar.gz
platform_external_arm-trusted-firmware-dad25049cec0e30ca9771e435064ebf853d97bba.tar.bz2
platform_external_arm-trusted-firmware-dad25049cec0e30ca9771e435064ebf853d97bba.zip
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
Diffstat (limited to 'include/stdlib')
-rw-r--r--include/stdlib/stdio.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/include/stdlib/stdio.h b/include/stdlib/stdio.h
index 60e081b43..57e5c7fa4 100644
--- a/include/stdlib/stdio.h
+++ b/include/stdlib/stdio.h
@@ -58,12 +58,13 @@ typedef __ssize_t ssize_t;
#define EOF (-1)
-int printf(const char * __restrict, ...);
+int printf(const char * __restrict, ...) __printflike(1, 2);
int putchar(int);
int puts(const char *);
-int sprintf(char * __restrict, const char * __restrict, ...);
+int sprintf(char * __restrict, const char * __restrict, ...)
+ __printflike(2, 3);
int vsprintf(char * __restrict, const char * __restrict,
- __va_list);
+ __va_list) __printflike(2, 0);
int sscanf(const char *__restrict, char const *__restrict, ...);