From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com
Subject: [Qemu-devel] [PATCH v4 09/22] qtest: Document calling conventions
Date: Thu, 3 Aug 2017 20:25:38 -0500 [thread overview]
Message-ID: <20170804012551.2714-10-eblake@redhat.com> (raw)
In-Reply-To: <20170804012551.2714-1-eblake@redhat.com>
We have two flavors of vararg usage in qtest: hmp() etc. work
like sprintf(), and 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 will 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 <eblake@redhat.com>
---
v4: rebase to %% handling, update commit message
v3: restore lost attributes, add comments on va_list forms, tweak
commit message to mention upcoming qmp cleanups
v2: several comment tweaks, explain why qmp() can't be marked
---
tests/libqtest.h | 40 +++++++++++++++++++++++++---------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/tests/libqtest.h b/tests/libqtest.h
index 3ae570927a..38148af66b 100644
--- a/tests/libqtest.h
+++ b/tests/libqtest.h
@@ -50,7 +50,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and consumes the response.
*/
@@ -59,7 +60,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and returns the response.
*/
@@ -68,7 +70,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and leaves the response in the stream.
*/
@@ -77,7 +80,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
* @ap: QMP message arguments
*
* Sends a QMP message to QEMU and consumes the response.
@@ -87,7 +91,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
* @ap: QMP message arguments
*
* Sends a QMP message to QEMU and returns the response.
@@ -97,7 +102,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
* @ap: QMP message arguments
*
* Sends a QMP message to QEMU and leaves the response in the stream.
@@ -134,19 +140,19 @@ QDict *qtest_qmp_eventwait_ref(QTestState *s, const char *event);
/**
* qtest_hmp:
* @s: #QTestState instance to operate on.
- * @fmt...: HMP command to send to QEMU
+ * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
*
* Send HMP command to QEMU via QMP's human-monitor-command.
* QMP events are discarded.
*
* Returns: the command's output. The caller should g_free() it.
*/
-char *qtest_hmp(QTestState *s, const char *fmt, ...);
+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.
@@ -154,7 +160,8 @@ char *qtest_hmp(QTestState *s, const char *fmt, ...);
*
* 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:
@@ -535,7 +542,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and returns the response.
*/
@@ -543,7 +551,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and leaves the response in the stream.
*/
@@ -551,7 +560,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 '%(PRI[ud]64|(l|ll)?[du]|[ipsf%])').
*
* Sends a QMP message to QEMU and consumes the response.
*/
@@ -592,13 +602,13 @@ static inline QDict *qmp_eventwait_ref(const char *event)
/**
* hmp:
- * @fmt...: HMP command to send to QEMU
+ * @fmt...: HMP command to send to QEMU, formats arguments like sprintf().
*
* Send HMP command to QEMU via QMP's human-monitor-command.
*
* Returns: the command's output. The caller should g_free() it.
*/
-char *hmp(const char *fmt, ...);
+char *hmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
/**
* get_irq:
--
2.13.3
next prev parent reply other threads:[~2017-08-04 1:26 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-04 1:25 [Qemu-devel] [PATCH v4 00/22] Clean up around qmp() and hmp() Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 01/22] qobject: Accept "%"PRId64 in qobject_from_jsonf() Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 02/22] tests: Clean up wait for event Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 03/22] tests/libqtest: Clean up how we read the QMP greeting Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 04/22] tests: Add assertion for no qmp("") Eric Blake
2017-08-09 7:13 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 05/22] qobject: Simplify qobject_from_jsonv() Eric Blake
2017-08-09 7:59 ` Markus Armbruster
2017-08-09 13:14 ` Eric Blake
2017-10-02 5:46 ` Markus Armbruster
2017-10-02 14:30 ` Eric Blake
2018-01-08 16:46 ` Eric Blake
2017-09-11 21:52 ` Eric Blake
2017-10-02 7:15 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 06/22] qobject: Perform %% interpolation in qobject_from_jsonf() Eric Blake
2017-08-09 9:06 ` Markus Armbruster
2017-08-09 13:21 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 07/22] numa-test: Use hmp() Eric Blake
2017-08-09 9:07 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 08/22] qtest: Avoid passing raw strings through hmp() Eric Blake
2017-08-04 1:25 ` Eric Blake [this message]
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 10/22] libqtest: Skip round-trip through QObject Eric Blake
2017-08-09 10:10 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 11/22] test-qga: Simplify command construction Eric Blake
2017-08-09 11:40 ` Markus Armbruster
2017-08-09 13:29 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 12/22] libqtest: Change qmp_fd_send() to drop varargs Eric Blake
2017-08-09 13:18 ` Markus Armbruster
2017-08-09 13:44 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 13/22] libqtest: Add qmp_raw() Eric Blake
2017-08-09 14:54 ` Markus Armbruster
2017-08-09 15:18 ` Eric Blake
2017-08-10 7:29 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 14/22] libqtest: Separate qmp_discard_response() from command Eric Blake
2017-08-09 15:15 ` Markus Armbruster
2017-08-09 15:32 ` Eric Blake
2017-08-10 7:40 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 15/22] libqtest: Delete qtest_qmp() wrappers Eric Blake
2017-08-09 15:34 ` Markus Armbruster
2017-08-09 16:35 ` Eric Blake
2017-08-10 7:47 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 16/22] libqtest: Add qmp_cmd() helper Eric Blake
2017-08-09 15:40 ` Markus Armbruster
2017-08-09 16:39 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 17/22] libqtest: Add qmp_args() helper Eric Blake
2017-08-09 15:57 ` Markus Armbruster
2017-08-09 21:57 ` Eric Blake
2017-08-10 8:17 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 18/22] tests/libqos/usb: Clean up string interpolation into QMP input Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 19/22] libqtest: Add qmp_args_dict() helper Eric Blake
2017-08-09 15:59 ` Markus Armbruster
2017-08-09 16:41 ` Eric Blake
2017-08-10 8:19 ` Markus Armbruster
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 20/22] tests/libqos/pci: Clean up string interpolation into QMP input Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 21/22] libqtest: Drop now-unused qmp() Eric Blake
2017-08-09 16:01 ` Markus Armbruster
2017-08-09 16:43 ` Eric Blake
2017-08-04 1:25 ` [Qemu-devel] [PATCH v4 22/22] libqtest: Rename qmp_cmd() to qmp() Eric Blake
2017-08-04 1:54 ` [Qemu-devel] [PATCH v4 00/22] Clean up around qmp() and hmp() no-reply
2017-08-04 11:50 ` Eric Blake
2017-08-04 12:10 ` Fam Zheng
2017-08-07 6:43 ` Fam Zheng
2017-08-07 7:33 ` Fam Zheng
2017-08-07 14:08 ` Philippe Mathieu-Daudé
2017-08-07 8:09 ` Fam Zheng
2017-08-04 2:02 ` no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170804012551.2714-10-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).