[git commit] Add some missing printf/scanf format attributes

Ron ron at debian.org
Fri Jun 26 19:14:16 UTC 2009


commit: http://git.uclibc.org/uClibc/commit/?id=443d0c54d0465071d3f9908c67449e526ea67795
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master


The gcc-4.4 documentation still suggests that the compiler will automatically
do format checking for the standard format function prototypes, but it is now
also barking warnings suggesting that we add them for this lot too. So added.

Signed-off-by: Ron Lee <ron at debian.org>
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
 include/stdio.h |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/include/stdio.h b/include/stdio.h
index dea839c..9336fe3 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -337,7 +337,8 @@ extern int printf (__const char *__restrict __format, ...);
 libc_hidden_proto(printf)
 /* Write formatted output to S.  */
 extern int sprintf (char *__restrict __s,
-		    __const char *__restrict __format, ...) __THROW;
+		    __const char *__restrict __format, ...)
+     __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
 libc_hidden_proto(sprintf)
 
 /* Write formatted output to S from argument list ARG.
@@ -354,7 +355,8 @@ libc_hidden_proto(vfprintf)
 extern int vprintf (__const char *__restrict __format, __gnuc_va_list __arg);
 /* Write formatted output to S from argument list ARG.  */
 extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
-		     __gnuc_va_list __arg) __THROW;
+		     __gnuc_va_list __arg)
+     __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
 __END_NAMESPACE_STD
 
 #if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
@@ -410,16 +412,19 @@ __BEGIN_NAMESPACE_STD
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
 extern int fscanf (FILE *__restrict __stream,
-		   __const char *__restrict __format, ...) __wur;
+		   __const char *__restrict __format, ...)
+     __attribute__ ((__format__ (__scanf__, 2, 3))) __wur;
 libc_hidden_proto(fscanf)
 /* Read formatted input from stdin.
 
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
-extern int scanf (__const char *__restrict __format, ...) __wur;
+extern int scanf (__const char *__restrict __format, ...)
+     __attribute__ ((__format__ (__scanf__, 1, 2))) __wur;
 /* Read formatted input from S.  */
 extern int sscanf (__const char *__restrict __s,
-		   __const char *__restrict __format, ...) __THROW;
+		   __const char *__restrict __format, ...)
+     __THROW __attribute__ ((__format__ (__scanf__, 2, 3)));
 libc_hidden_proto(sscanf)
 __END_NAMESPACE_STD
 
-- 
1.6.3.3


More information about the uClibc-cvs mailing list