diff mbox

[7/9] Add -Wmissing-format-attribute & fix problems it finds

Message ID 1333363816-1691-8-git-send-email-berrange@redhat.com
State New
Headers show

Commit Message

Daniel P. Berrangé April 2, 2012, 10:50 a.m. UTC
From: "Daniel P. Berrange" <berrange@redhat.com>

* configure: Add -Wmissing-format-attribute
* hw/qxl.c: Add missing format attribute to qxl_guest_bug
  and fix format specifiers in a caller of it
* qtest.c: Add missing format attribute to qtest_send

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 configure |    1 +
 hw/qxl.c  |    4 ++--
 qtest.c   |    2 +-
 3 files changed, 4 insertions(+), 3 deletions(-)

Comments

Andreas Färber April 2, 2012, 12:49 p.m. UTC | #1
Am 02.04.2012 12:50, schrieb Daniel P. Berrange:
> From: "Daniel P. Berrange" <berrange@redhat.com>
> 
> * configure: Add -Wmissing-format-attribute
> * hw/qxl.c: Add missing format attribute to qxl_guest_bug
>   and fix format specifiers in a caller of it
> * qtest.c: Add missing format attribute to qtest_send

There were patches for both of these on the list already:

http://patchwork.ozlabs.org/patch/149983/
http://patchwork.ozlabs.org/patch/149835/

Andreas

> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  configure |    1 +
>  hw/qxl.c  |    4 ++--
>  qtest.c   |    2 +-
>  3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index 8ee6cdb..3d47440 100755
> --- a/configure
> +++ b/configure
> @@ -1193,6 +1193,7 @@ gcc_flags="$gcc_flags -Wtrampolines"
>  gcc_flags="$gcc_flags -Wmissing-parameter-type"
>  gcc_flags="$gcc_flags -Wuninitialized"
>  gcc_flags="$gcc_flags -Wlogical-op"
> +gcc_flags="$gcc_flags -Wmissing-format-attribute"
>  
>  cat > $TMPC << EOF
>  int main(void) { return 0; }
> diff --git a/hw/qxl.c b/hw/qxl.c
> index 47a162e..33b2288 100644
> --- a/hw/qxl.c
> +++ b/hw/qxl.c
> @@ -124,7 +124,7 @@ static void qxl_reset_memslots(PCIQXLDevice *d);
>  static void qxl_reset_surfaces(PCIQXLDevice *d);
>  static void qxl_ring_set_dirty(PCIQXLDevice *qxl);
>  
> -void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
> +GCC_FMT_ATTR(2, 3) void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
>  {
>      qxl_send_events(qxl, QXL_INTERRUPT_ERROR);
>      if (qxl->guestdebug) {
> @@ -1370,7 +1370,7 @@ async_common:
>      case QXL_IO_DESTROY_SURFACE_WAIT:
>          if (val >= NUM_SURFACES) {
>              qxl_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
> -                             "%d >= NUM_SURFACES", async, val);
> +                             "%"PRIx64" >= NUM_SURFACES", async, val);
>              goto cancel_async;
>          }
>          qxl_spice_destroy_surface_wait(d, val, async);
> diff --git a/qtest.c b/qtest.c
> index cd7186c..2b71de3 100644
> --- a/qtest.c
> +++ b/qtest.c
> @@ -156,7 +156,7 @@ static void qtest_send_prefix(CharDriverState *chr)
>              tv.tv_sec, tv.tv_usec);
>  }
>  
> -static void qtest_send(CharDriverState *chr, const char *fmt, ...)
> +GCC_FMT_ATTR(2, 3) static void qtest_send(CharDriverState *chr, const char *fmt, ...)
>  {
>      va_list ap;
>      char buffer[1024];
diff mbox

Patch

diff --git a/configure b/configure
index 8ee6cdb..3d47440 100755
--- a/configure
+++ b/configure
@@ -1193,6 +1193,7 @@  gcc_flags="$gcc_flags -Wtrampolines"
 gcc_flags="$gcc_flags -Wmissing-parameter-type"
 gcc_flags="$gcc_flags -Wuninitialized"
 gcc_flags="$gcc_flags -Wlogical-op"
+gcc_flags="$gcc_flags -Wmissing-format-attribute"
 
 cat > $TMPC << EOF
 int main(void) { return 0; }
diff --git a/hw/qxl.c b/hw/qxl.c
index 47a162e..33b2288 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -124,7 +124,7 @@  static void qxl_reset_memslots(PCIQXLDevice *d);
 static void qxl_reset_surfaces(PCIQXLDevice *d);
 static void qxl_ring_set_dirty(PCIQXLDevice *qxl);
 
-void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
+GCC_FMT_ATTR(2, 3) void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
 {
     qxl_send_events(qxl, QXL_INTERRUPT_ERROR);
     if (qxl->guestdebug) {
@@ -1370,7 +1370,7 @@  async_common:
     case QXL_IO_DESTROY_SURFACE_WAIT:
         if (val >= NUM_SURFACES) {
             qxl_guest_bug(d, "QXL_IO_DESTROY_SURFACE (async=%d):"
-                             "%d >= NUM_SURFACES", async, val);
+                             "%"PRIx64" >= NUM_SURFACES", async, val);
             goto cancel_async;
         }
         qxl_spice_destroy_surface_wait(d, val, async);
diff --git a/qtest.c b/qtest.c
index cd7186c..2b71de3 100644
--- a/qtest.c
+++ b/qtest.c
@@ -156,7 +156,7 @@  static void qtest_send_prefix(CharDriverState *chr)
             tv.tv_sec, tv.tv_usec);
 }
 
-static void qtest_send(CharDriverState *chr, const char *fmt, ...)
+GCC_FMT_ATTR(2, 3) static void qtest_send(CharDriverState *chr, const char *fmt, ...)
 {
     va_list ap;
     char buffer[1024];