Re: [Qemu-devel] [PATCH 17/20] migration-test: Clean up string interpolation into QMP, part 1
Juan Quintela writes: > Markus Armbruster wrote: >> 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 > > Why, o why it needs to be so difficult!!! At least the series improves the interface from Rusty's API level -4 "Follow common convention and you'll get it wrong" to API level 4 "Follow common convention and you'll get it right", and for some kind of mistakes even to API level 8 "The compiler will warn if you get it wrong." Thanks!
Re: [Qemu-devel] [PATCH 17/20] migration-test: Clean up string interpolation into QMP, part 1
Markus Armbruster wrote: > 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 Why, o why it needs to be so difficult!!!
[Qemu-devel] [PATCH 17/20] 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 --- tests/migration-test.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index 55f9d006ec..66a4cd2395 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -355,13 +355,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