[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/25] migration-test: Clean up string interpolation
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PULL 18/25] migration-test: Clean up string interpolation into QMP, part 1 |
Date: |
Thu, 16 Aug 2018 10:36:54 +0200 |
Leaving interpolation into JSON to qmp() is more robust than building
QMP input manually, as explained in the recent commit "tests: Clean up
string interpolation into QMP input (simple cases)".
migrate_recover() builds QMP input manually because wait_command()
can't interpolate. Well, it can since the previous commit. Simplify
accordingly.
Bonus: gets rid of a non-literal format string. A step towards
compile-time format string checking without triggering
-Wformat-nonliteral.
Cc: Juan Quintela <address@hidden>
Cc: Dr. David Alan Gilbert <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Juan Quintela <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
---
tests/migration-test.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tests/migration-test.c b/tests/migration-test.c
index 7bffcd2e4d..4b8d4cc119 100644
--- a/tests/migration-test.c
+++ b/tests/migration-test.c
@@ -159,6 +159,7 @@ static void stop_cb(void *opaque, const char *name, QDict
*data)
/*
* Events can get in the way of responses we are actually waiting for.
*/
+GCC_FMT_ATTR(2, 3)
static QDict *wait_command(QTestState *who, const char *command, ...)
{
va_list ap;
@@ -357,13 +358,12 @@ static void migrate_pause(QTestState *who)
static void migrate_recover(QTestState *who, const char *uri)
{
QDict *rsp;
- gchar *cmd = g_strdup_printf(
- "{ 'execute': 'migrate-recover', "
- " 'id': 'recover-cmd', "
- " 'arguments': { 'uri': '%s' } }", uri);
- rsp = wait_command(who, cmd);
- g_free(cmd);
+ rsp = wait_command(who,
+ "{ 'execute': 'migrate-recover', "
+ " 'id': 'recover-cmd', "
+ " 'arguments': { 'uri': %s } }",
+ uri);
qobject_unref(rsp);
}
--
2.17.1
- [Qemu-devel] [PULL 01/25] libqtest: Rename functions to send QMP messages, (continued)
- [Qemu-devel] [PULL 01/25] libqtest: Rename functions to send QMP messages, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 08/25] libqtest: Simplify qmp_fd_vsend() a bit, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 04/25] libqtest: Remove qtest_qmp_discard_response() & friends, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 25/25] libqtest: Improve error reporting for bad read from QEMU, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 07/25] qobject: New qobject_from_vjsonf_nofail(), qdict_from_vjsonf_nofail(), Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 02/25] libqtest: Clean up how we read device_del messages, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 03/25] libqtest: Clean up how we read the QMP greeting, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 10/25] qobject: qobject_from_jsonv() is dangerous, hide it away, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 05/25] libqtest: Document calling conventions, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 06/25] qobject: Replace qobject_from_jsonf() by qobject_from_jsonf_nofail(), Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 18/25] migration-test: Clean up string interpolation into QMP, part 1,
Markus Armbruster <=
- [Qemu-devel] [PULL 22/25] libqtest: Replace qtest_startf() by qtest_initf(), Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 17/25] migration-test: Make wait_command() cope with '%', Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 23/25] libqtest: Rename qtest_FOOv() to qtest_vFOO() for consistency, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 09/25] test-qobject-input-visitor: Avoid format string ambiguity, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 20/25] migration-test: Clean up string interpolation into QMP, part 3, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 13/25] cpu-plug-test: Don't pass integers as strings to device_add, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 11/25] tests: Pass literal format strings directly to qmp_FOO(), Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 15/25] migration-test: Make wait_command() return the "return" member, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 19/25] migration-test: Clean up string interpolation into QMP, part 2, Markus Armbruster, 2018/08/16
- [Qemu-devel] [PULL 16/25] tests: New helper qtest_qmp_receive_success(), Markus Armbruster, 2018/08/16