Skip to contentSkip to conversation

readline: Add missing GCC_FMT_ATTR

PATCH Applied Stefan Weil 3 participants 3 messages Jan 25, 2014 – Feb 1, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 readline: Add missing GCC_FMT_ATTR

This fixes a compiler warning with -Werror=missing-format-attribute and allows improved compiler checks for variable argument lists.

---
 include/qemu/readline.h |    3 ++-
 monitor.c               |    3 ++-
 qemu-io.c               |    3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
include/qemu/readline.h +2 -1
index a89fe4a..49efe4e 100644
@@ -5,7 +5,8 @@
 #define READLINE_MAX_CMDS 64
 #define READLINE_MAX_COMPLETIONS 256
 
-typedef void ReadLinePrintfFunc(void *opaque, const char *fmt, ...);
+typedef void GCC_FMT_ATTR(2, 3) ReadLinePrintfFunc(void *opaque,
+                                                   const char *fmt, ...);
 typedef void ReadLineFlushFunc(void *opaque);
 typedef void ReadLineFunc(void *opaque, const char *str,
                           void *readline_opaque);
monitor.c +2 -1
index 80456fb..5ba541d 100644
@@ -4888,7 +4888,8 @@ static void sortcmdlist(void)
 /* These functions just adapt the readline interface in a typesafe way.  We
  * could cast function pointers but that discards compiler checks.
  */
-static void monitor_readline_printf(void *opaque, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3) monitor_readline_printf(void *opaque,
+                                                       const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
qemu-io.c +2 -1
index d669028..7f459d8 100644
@@ -219,7 +219,8 @@ static char *get_prompt(void)
     return prompt;
 }
 
-static void readline_printf_func(void *opaque, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3) readline_printf_func(void *opaque,
+                                                    const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
Signature · 1 line
1.7.10.4
#2 lore raw
In reply to Stefan Weil
Quoted 2 lines · Stefan Weil

This fixes a compiler warning with -Werror=missing-format-attribute and allows improved compiler checks for variable argument lists.

Thanks, applied to the trivial-patches queue.

/mjt