From 0f28bc489d467172e33182d3b27b21a1eefe38d0 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 15 Jan 2021 11:51:22 +0100 Subject: [PATCH] software/include/base/stdio: Enable printf format strings checks Now all format issues are fixed, tag all functions taking printf()-style format specifiers with "__attribute__((format(printf, ...))", enabling format string checks ("-Wall" includes "-Wformat"). Signed-off-by: Geert Uytterhoeven --- litex/soc/software/include/base/stdio.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/litex/soc/software/include/base/stdio.h b/litex/soc/software/include/base/stdio.h index 5e872d64e..f070cf123 100644 --- a/litex/soc/software/include/base/stdio.h +++ b/litex/soc/software/include/base/stdio.h @@ -10,11 +10,11 @@ extern "C" { int putchar(int c); int puts(const char *s); -int snprintf(char *buf, size_t size, const char *fmt, ...); -int scnprintf(char *buf, size_t size, const char *fmt, ...); -int sprintf(char *buf, const char *fmt, ...); +int snprintf(char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +int scnprintf(char *buf, size_t size, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +int sprintf(char *buf, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int printf(const char *fmt, ...); +int printf(const char *fmt, ...) __attribute__((format(printf, 1, 2))); /* Not sure this belongs here... */ typedef long long loff_t; @@ -53,7 +53,7 @@ extern FILE *stdin; extern FILE *stdout; extern FILE *stderr; -int fprintf(FILE *stream, const char *format, ...); +int fprintf(FILE *stream, const char *format, ...) __attribute__((format(printf, 2, 3))); int fflush(FILE *stream); FILE *fopen(const char *path, const char *mode);