From: Markus Armbruster Date: Mon, 6 Aug 2018 06:53:39 +0000 (+0200) Subject: migration-test: Clean up string interpolation into QMP, part 1 X-Git-Tag: v3.1.0-rc0~138^2~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b7281c6989c09a98670ea11c588b17737c846154;p=thirdparty%2Fqemu.git migration-test: Clean up string interpolation into QMP, part 1 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 Cc: Dr. David Alan Gilbert Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela Reviewed-by: Eric Blake Message-Id: <20180806065344.7103-19-armbru@redhat.com> --- diff --git a/tests/migration-test.c b/tests/migration-test.c index 7bffcd2e4d4..4b8d4cc1199 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); }