From patchwork Sat Feb 16 21:44:02 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: 221038 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 5DE852C008D for ; Sun, 17 Feb 2013 08:44:42 +1100 (EST) Received: from localhost ([::1]:58039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6pYm-0000eZ-DA for incoming@patchwork.ozlabs.org; Sat, 16 Feb 2013 16:44:40 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6pYV-0000UO-EA for qemu-devel@nongnu.org; Sat, 16 Feb 2013 16:44:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6pYS-000387-0t for qemu-devel@nongnu.org; Sat, 16 Feb 2013 16:44:23 -0500 Received: from cantor2.suse.de ([195.135.220.15]:50181 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6pYR-00037n-Os for qemu-devel@nongnu.org; Sat, 16 Feb 2013 16:44:19 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3FD0DA398D; Sat, 16 Feb 2013 22:44:19 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sat, 16 Feb 2013 22:44:02 +0100 Message-Id: <1361051043-27944-3-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361051043-27944-1-git-send-email-afaerber@suse.de> References: <1361051043-27944-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 v4 2/3] 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: