[coreboot] New patch to review for coreboot: d123b86 libpayload: Add the format attribute to functions in stdio.h.

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Wed Nov 7 00:22:03 CET 2012

Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1731


commit d123b8636ccba8894332c70c48802e8e6ca9be55
Author: Gabe Black <gabeblack at google.com>
Date:   Tue Oct 2 00:32:59 2012 -0700

    libpayload: Add the format attribute to functions in stdio.h.
    gcc recognizes the format function attribute which tells the compiler to expect
    the format string to look a certain way and for its arguments to be of
    appropriate types. This helps to prevent errors like the one that was recently
    fixed in libpayload's assert.
    Change-Id: I284ae8bff32f72cfd2d1a250d126c729b38a5730
    Signed-off-by: Gabe Black <gabeblack at google.com>
 payloads/libpayload/include/stdio.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/payloads/libpayload/include/stdio.h b/payloads/libpayload/include/stdio.h
index 924d17e..d2db640 100644
--- a/payloads/libpayload/include/stdio.h
+++ b/payloads/libpayload/include/stdio.h
@@ -42,10 +42,14 @@ extern FILE *stdout, *stdin, *stderr;
  * @defgroup printf Print functions
  * @{
-int snprintf(char *str, size_t size, const char *fmt, ...);
-int sprintf(char *str, const char *fmt, ...);
-int printf(const char *fmt, ...);
-int fprintf(FILE *file, const char *fmt, ...);
+int snprintf(char *str, size_t size, const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+int sprintf(char *str, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
+int printf(const char *fmt, ...)
+	__attribute__ ((format (printf, 1, 2)));
+int fprintf(FILE *file, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
 /** @} */
 void perror(const char *s);

More information about the coreboot mailing list