Skip to contentSkip to conversation

Trivial portability fix: missing va_end()

PATCH Applied Markus Armbruster 2 participants 5 messages Oct 28, 2011 – Oct 31, 2011

lore
Share & tools
lore
#0 lore raw

cover Trivial portability fix: missing va_end()

Markus Armbruster (2):
sysbus: Supply missing va_end()
hw/9pfs: Supply missing va_end()

 hw/9pfs/virtio-9p.c |    4 ++++
 hw/sysbus.c         |    2 ++
 2 files changed, 6 insertions(+), 0 deletions(-)
Signature · 1 line
1.7.6.4
#3 lore raw

PATCH 2/2 hw/9pfs: Supply missing va_end()

C99 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.

Spotted by Coverity. Harmless on the (common) systems where va_end() does nothing.

---
 hw/9pfs/virtio-9p.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
hw/9pfs/virtio-9p.c +4 -0
index aab3beb..1e22696 100644
@@ -231,6 +231,7 @@ v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
                 arg_ulong = va_arg(ap2, unsigned long);
                 len += number_to_string((void *)&arg_ulong, 'U');
             } else {
+                va_end(ap2);
                 return -1;
             }
             break;
@@ -244,11 +245,14 @@ v9fs_string_alloc_printf(char **strp, const char *fmt, va_list ap)
         default:
             fprintf(stderr,
 		    "v9fs_string_alloc_printf:Incorrect format %c", *iter);
+            va_end(ap2);
             return -1;
         }
         iter++;
     }
 
+    va_end(ap2);
+
 alloc_print:
     *strp = g_malloc((len + 1) * sizeof(**strp));
 
Signature · 1 line
1.7.6.4
#1 lore raw

PATCH 1/2 sysbus: Supply missing va_end()

In reply to Markus Armbruster

C99 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.

Spotted by Coverity. Harmless on the (common) systems where va_end() does nothing.

---
 hw/sysbus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/sysbus.c +2 -0
index 4fab5a4..fd2fc6a 100644
@@ -198,6 +198,7 @@ DeviceState *sysbus_create_varargs(const char *name,
         sysbus_connect_irq(s, n, irq);
         n++;
     }
+    va_end(va);
     return dev;
 }
 
@@ -229,6 +230,7 @@ DeviceState *sysbus_try_create_varargs(const char *name,
         sysbus_connect_irq(s, n, irq);
         n++;
     }
+    va_end(va);
     return dev;
 }
 
Signature · 1 line
1.7.6.4
#4 lore raw

Re: [Qemu-devel] [Qemu-trivial] [PATCH 2/2] hw/9pfs: Supply missing va_end()

In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster

C99 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.

Spotted by Coverity.  Harmless on the (common) systems where va_end() does nothing.

---
 hw/9pfs/virtio-9p.c |    4 ++++

 1 files changed, 4 insertions(+), 0 deletions(-)

Thanks for this patch. I looked at the surrounding code and it turns out this entire function duplicates g_vasprintf() from glib.

I sent a patch to use g_vasprintf() and it therefore eliminates the varargs issue.

Stefan

#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] sysbus: Supply missing va_end()

In reply to Markus Armbruster
Quoted 11 lines · Markus Armbruster

C99 7.15.1: Each invocation of the va_start and va_copy macros shall be matched by a corresponding invocation of the va_end macro in the same function.

Spotted by Coverity. Harmless on the (common) systems where va_end() does nothing.

---
 hw/sysbus.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Thanks, applied to the trivial patches -next tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches-next

Stefan