qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-9p: Use GCC_FMT_ATTR and fix a format warning
@ 2010-09-27 16:45 Stefan Weil
  2010-10-03  7:49 ` [Qemu-devel] " Blue Swirl
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Weil @ 2010-09-27 16:45 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Blue Swirl

With the new gcc format warnings, gcc detected this:

/qemu/hw/virtio-9p.c:1040: error: format ‘%u’ expects type ‘unsigned int’, but argument 4 has type ‘__nlink_t’

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/virtio-9p.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 32fa3bc..3b2d49c 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -333,7 +333,8 @@ static int number_to_string(void *arg, char type)
     return ret;
 }
 
-static int v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
+static int GCC_FMT_ATTR(2, 0)
+v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
 {
     va_list ap2;
     char *iter = (char *)fmt;
@@ -387,7 +388,8 @@ alloc_print:
     return vsprintf(*strp, fmt, ap);
 }
 
-static void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
+static void GCC_FMT_ATTR(2, 3)
+v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
 {
     va_list ap;
     int err;
@@ -1034,8 +1036,8 @@ static int stat_to_v9stat(V9fsState *s, V9fsString *name,
                 S_ISCHR(stbuf->st_mode) ? 'c' : 'b',
                 major(stbuf->st_rdev), minor(stbuf->st_rdev));
     } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) {
-        v9fs_string_sprintf(&v9stat->extension, "%s %u",
-                "HARDLINKCOUNT", stbuf->st_nlink);
+        v9fs_string_sprintf(&v9stat->extension, "%s %lu",
+                "HARDLINKCOUNT", (unsigned long)stbuf->st_nlink);
     }
 
     str = strrchr(name->data, '/');
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Qemu-devel] Re: [PATCH] virtio-9p: Use GCC_FMT_ATTR and fix a format warning
  2010-09-27 16:45 [Qemu-devel] [PATCH] virtio-9p: Use GCC_FMT_ATTR and fix a format warning Stefan Weil
@ 2010-10-03  7:49 ` Blue Swirl
  0 siblings, 0 replies; 2+ messages in thread
From: Blue Swirl @ 2010-10-03  7:49 UTC (permalink / raw)
  To: Stefan Weil; +Cc: QEMU Developers

Thanks, applied.

On Mon, Sep 27, 2010 at 4:45 PM, Stefan Weil <weil@mail.berlios.de> wrote:
> With the new gcc format warnings, gcc detected this:
>
> /qemu/hw/virtio-9p.c:1040: error: format ‘%u’ expects type ‘unsigned int’, but argument 4 has type ‘__nlink_t’
>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/virtio-9p.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
> index 32fa3bc..3b2d49c 100644
> --- a/hw/virtio-9p.c
> +++ b/hw/virtio-9p.c
> @@ -333,7 +333,8 @@ static int number_to_string(void *arg, char type)
>     return ret;
>  }
>
> -static int v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
> +static int GCC_FMT_ATTR(2, 0)
> +v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
>  {
>     va_list ap2;
>     char *iter = (char *)fmt;
> @@ -387,7 +388,8 @@ alloc_print:
>     return vsprintf(*strp, fmt, ap);
>  }
>
> -static void v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
> +static void GCC_FMT_ATTR(2, 3)
> +v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
>  {
>     va_list ap;
>     int err;
> @@ -1034,8 +1036,8 @@ static int stat_to_v9stat(V9fsState *s, V9fsString *name,
>                 S_ISCHR(stbuf->st_mode) ? 'c' : 'b',
>                 major(stbuf->st_rdev), minor(stbuf->st_rdev));
>     } else if (S_ISDIR(stbuf->st_mode) || S_ISREG(stbuf->st_mode)) {
> -        v9fs_string_sprintf(&v9stat->extension, "%s %u",
> -                "HARDLINKCOUNT", stbuf->st_nlink);
> +        v9fs_string_sprintf(&v9stat->extension, "%s %lu",
> +                "HARDLINKCOUNT", (unsigned long)stbuf->st_nlink);
>     }
>
>     str = strrchr(name->data, '/');
> --
> 1.7.1
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-03  7:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27 16:45 [Qemu-devel] [PATCH] virtio-9p: Use GCC_FMT_ATTR and fix a format warning Stefan Weil
2010-10-03  7:49 ` [Qemu-devel] " Blue Swirl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).