summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-05-20 10:28:12 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-06-09 11:58:21 +0200
commit064cee5a224129d200a4a32a27e2ba8114a2b564 (patch)
tree62e8e0e2fa45bc9d1bff04bb283029b94649acb1
parent1b8b9c142fb8735ca5a5806ce92ac2e327131f6d (diff)
kern: add function attributes to the printf-functions
* kern/printf.h (sprintf, snprintf, vsnprintf, printf): Add the `printf' function attribute that allows the compiler to check the format strings and arguments.
-rw-r--r--kern/printf.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/kern/printf.h b/kern/printf.h
index 0f8b328..86857d3 100644
--- a/kern/printf.h
+++ b/kern/printf.h
@@ -39,11 +39,16 @@ extern void printnum (unsigned long u, int base,
void (*putc)(char, vm_offset_t),
vm_offset_t putc_arg);
-extern int sprintf (char *buf, const char *fmt, ...);
-extern int snprintf (char *buf, size_t size, const char *fmt, ...);
-extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args);
+extern int sprintf (char *buf, const char *fmt, ...)
+ __attribute__ ((format (printf, 2, 3)));
+extern int snprintf (char *buf, size_t size, const char *fmt, ...)
+ __attribute__ ((format (printf, 3, 4)));
+extern int vsnprintf (char *buf, size_t size, const char *fmt, va_list args)
+ __attribute__ ((format (printf, 3, 0)));
-extern int printf (const char *fmt, ...);
+
+extern int printf (const char *fmt, ...)
+ __attribute__ ((format (printf, 1, 2)));
#define printf_once(fmt, ...) \
MACRO_BEGIN \