From patchwork Mon Feb 11 19:01:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 219665 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 703162C02C7 for ; Tue, 12 Feb 2013 06:01:55 +1100 (EST) Received: from localhost ([::1]:47835 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4ydV-0007L2-HP for incoming@patchwork.ozlabs.org; Mon, 11 Feb 2013 14:01:53 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4ydD-0007Bo-QG for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U4yd7-0006ch-4A for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:35 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45594 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U4yd6-0006cP-Rr for qemu-devel@nongnu.org; Mon, 11 Feb 2013 14:01:29 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 54A6AA4E82; Mon, 11 Feb 2013 20:01:28 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Mon, 11 Feb 2013 20:01:21 +0100 Message-Id: <1360609282-22051-5-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360609282-22051-1-git-send-email-afaerber@suse.de> References: <1360609282-22051-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , anthony@codemonkey.ws Subject: [Qemu-devel] [PATCH for-next v3 4/5] libqtest: Introduce qtest_qmpv() and convert remaining macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- tests/libqtest.c | 14 ++++++++++---- tests/libqtest.h | 20 +++++++++++++++++++- 2 Dateien geändert, 29 Zeilen hinzugefügt(+), 5 Zeilen entfernt(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 762dec4..da58ff5 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -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"); diff --git a/tests/libqtest.h b/tests/libqtest.h index a111c9c..f5c6e21 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -17,6 +17,7 @@ #include #include +#include #include typedef struct QTestState QTestState; @@ -49,6 +50,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. * @num: Interrupt to observe. @@ -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: