]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuMonitorJSONCheckReply: Use g_autofree
authorYi Li <yili@winhong.com>
Wed, 21 Oct 2020 09:23:40 +0000 (17:23 +0800)
committerJán Tomko <jtomko@redhat.com>
Mon, 26 Oct 2020 17:23:10 +0000 (18:23 +0100)
Eliminate cleanup code by using g_autofree.

Signed-off-by: Yi Li <yili@winhong.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_monitor_json.c

index 445d7949053b964f5a199877f34bf7b869631eff..843a555952ba9a446f9dd3aee887835ec292bb21 100644 (file)
@@ -457,8 +457,8 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
 
     data = virJSONValueObjectGet(reply, "return");
     if (virJSONValueGetType(data) != type) {
-        char *cmdstr = virJSONValueToString(cmd, false);
-        char *retstr = virJSONValueToString(data, false);
+        g_autofree char *cmdstr = virJSONValueToString(cmd, false);
+        g_autofree char *retstr = virJSONValueToString(data, false);
 
         VIR_DEBUG("Unexpected return type %d (expecting %d) for command %s: %s",
                   virJSONValueGetType(data), type, cmdstr, retstr);
@@ -466,8 +466,6 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
                        _("unexpected type returned by QEMU command '%s'"),
                        qemuMonitorJSONCommandName(cmd));
 
-        VIR_FREE(cmdstr);
-        VIR_FREE(retstr);
         return -1;
     }