]> git.proxmox.com Git - qemu.git/commitdiff
libqtest: Introduce qtest_qmpv() and convert remaining macro
authorAndreas Färber <afaerber@suse.de>
Sat, 16 Feb 2013 21:44:02 +0000 (22:44 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 18 Feb 2013 14:39:09 +0000 (08:39 -0600)
In order to convert qmp() macro to an inline function, expose a
qtest_qmpv() function, reused by qtest_qmp().

We can't apply GCC_FMT_ATTR() since fdc-test is using zero-length format
strings, which would result in warnings treated as errors.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Andreas Färber <afaerber@suse.de>
Message-id: 1361051043-27944-3-git-send-email-afaerber@suse.de
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
tests/libqtest.c
tests/libqtest.h

index 762dec4ac0319fe24ddc2fff09d4d0e43c2a2aa6..da58ff503469b867d7912da88006e619d15bf578 100644 (file)
@@ -288,16 +288,13 @@ redo:
     return words;
 }
 
-void qtest_qmp(QTestState *s, const char *fmt, ...)
+void qtest_qmpv(QTestState *s, const char *fmt, va_list ap)
 {
-    va_list ap;
     bool has_reply = false;
     int nesting = 0;
 
     /* Send QMP request */
-    va_start(ap, fmt);
     socket_sendf(s->qmp_fd, fmt, ap);
-    va_end(ap);
 
     /* Receive reply */
     while (!has_reply || nesting > 0) {
@@ -326,6 +323,15 @@ void qtest_qmp(QTestState *s, const char *fmt, ...)
     }
 }
 
+void qtest_qmp(QTestState *s, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    qtest_qmpv(s, fmt, ap);
+    va_end(ap);
+}
+
 const char *qtest_get_arch(void)
 {
     const char *qemu = getenv("QTEST_QEMU_BINARY");
index a111c9cddbb5307cdf616bcec3522c84a10bd950..f5c6e21d459d27ef09d720575df2a99bebd369ea 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
+#include <stdarg.h>
 #include <sys/types.h>
 
 typedef struct QTestState QTestState;
@@ -48,6 +49,16 @@ void qtest_quit(QTestState *s);
  */
 void qtest_qmp(QTestState *s, const char *fmt, ...);
 
+/**
+ * qtest_qmpv:
+ * @s: #QTestState instance to operate on.
+ * @fmt: QMP message to send to QEMU
+ * @ap: QMP message arguments
+ *
+ * Sends a QMP message to QEMU.
+ */
+void qtest_qmpv(QTestState *s, const char *fmt, va_list ap);
+
 /**
  * qtest_get_irq:
  * @s: #QTestState instance to operate on.
@@ -227,7 +238,14 @@ static inline QTestState *qtest_start(const char *args)
  *
  * Sends a QMP message to QEMU
  */
-#define qmp(fmt, ...) qtest_qmp(global_qtest, fmt, ## __VA_ARGS__)
+static inline void qmp(const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    qtest_qmpv(global_qtest, fmt, ap);
+    va_end(ap);
+}
 
 /**
  * get_irq: