From patchwork Thu Jul 12 11:12:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 942945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41RDCP11tzz9rxs for ; Thu, 12 Jul 2018 21:26:09 +1000 (AEST) Received: from localhost ([::1]:58730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdZja-0000fy-22 for incoming@patchwork.ozlabs.org; Thu, 12 Jul 2018 07:26:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fdZWN-00077A-L3 for qemu-devel@nongnu.org; Thu, 12 Jul 2018 07:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fdZWK-0006nU-AR for qemu-devel@nongnu.org; Thu, 12 Jul 2018 07:12:27 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37006 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fdZWK-0006mX-2g for qemu-devel@nongnu.org; Thu, 12 Jul 2018 07:12:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7BBBD4059FE2 for ; Thu, 12 Jul 2018 11:12:23 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-125.ams2.redhat.com [10.36.116.125]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2AB922156889; Thu, 12 Jul 2018 11:12:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C21FA1138529; Thu, 12 Jul 2018 13:12:21 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 12 Jul 2018 13:12:02 +0200 Message-Id: <20180712111221.20326-2-armbru@redhat.com> In-Reply-To: <20180712111221.20326-1-armbru@redhat.com> References: <20180712111221.20326-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 12 Jul 2018 11:12:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 12 Jul 2018 11:12:23 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'armbru@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 01/20] libqtest: Document calling conventions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Eric Blake We have two flavors of vararg usage in qtest: qtest_hmp() etc. work like sprintf(), and qtest_qmp() etc. work like qobject_from_jsonf(). Spell that out in the comments. Also add GCC_FMT_ATTR() to qtest_hmp() etc. so that the compiler can flag incorrect use. We have some cleanup work to do before we can do the same for qtest_qmp() etc. This would get us the same better-than-nothing checking we already have for qobject_from_jsonf(): common incorrect uses of supported conversion specifications will be flagged (e.g. passing a double for %d), but use of unsupported ones won't. Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Markus Armbruster [Rebased, commit message rewritten] Signed-off-by: Markus Armbruster --- tests/libqtest.h | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/tests/libqtest.h b/tests/libqtest.h index ac52872cbe..c63551f14f 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -76,7 +76,8 @@ void qtest_quit(QTestState *s); /** * qtest_qmp_discard_response: * @s: #QTestState instance to operate on. - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and consumes the response. */ @@ -85,7 +86,8 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...); /** * qtest_qmp: * @s: #QTestState instance to operate on. - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and returns the response. */ @@ -94,7 +96,8 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...); /** * qtest_async_qmp: * @s: #QTestState instance to operate on. - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and leaves the response in the stream. */ @@ -103,7 +106,8 @@ void qtest_async_qmp(QTestState *s, const char *fmt, ...); /** * qtest_qmpv_discard_response: * @s: #QTestState instance to operate on. - * @fmt: QMP message to send to QEMU + * @fmt: QMP message to send to QEMU; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * @ap: QMP message arguments * * Sends a QMP message to QEMU and consumes the response. @@ -113,7 +117,8 @@ void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap); /** * qtest_qmpv: * @s: #QTestState instance to operate on. - * @fmt: QMP message to send to QEMU + * @fmt: QMP message to send to QEMU; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * @ap: QMP message arguments * * Sends a QMP message to QEMU and returns the response. @@ -123,7 +128,8 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap); /** * qtest_async_qmpv: * @s: #QTestState instance to operate on. - * @fmt: QMP message to send to QEMU + * @fmt: QMP message to send to QEMU; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * @ap: QMP message arguments * * Sends a QMP message to QEMU and leaves the response in the stream. @@ -172,7 +178,7 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); /** * qtest_hmpv: * @s: #QTestState instance to operate on. - * @fmt: HMP command to send to QEMU + * @fmt: HMP command to send to QEMU, formats arguments like vsprintf(). * @ap: HMP command arguments * * Send HMP command to QEMU via QMP's human-monitor-command. @@ -180,7 +186,8 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3); * * Returns: the command's output. The caller should g_free() it. */ -char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap); +char *qtest_hmpv(QTestState *s, const char *fmt, va_list ap) + GCC_FMT_ATTR(2, 0); /** * qtest_get_irq: @@ -561,7 +568,8 @@ static inline void qtest_end(void) /** * qmp: - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and returns the response. */ @@ -569,7 +577,8 @@ QDict *qmp(const char *fmt, ...); /** * qmp_async: - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and leaves the response in the stream. */ @@ -577,7 +586,8 @@ void qmp_async(const char *fmt, ...); /** * qmp_discard_response: - * @fmt...: QMP message to send to qemu + * @fmt...: QMP message to send to qemu; formats arguments through + * json-lexer.c (only understands '%((l|ll|I64)?d|[ipsf])'). * * Sends a QMP message to QEMU and consumes the response. */