[PATCH v3] qemuMonitorJSONCheckReply: Use g_autofree

Yi Li posted 1 patch 3 years, 6 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20201021092340.3236836-1-yili@winhong.com
src/qemu/qemu_monitor_json.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH v3] qemuMonitorJSONCheckReply: Use g_autofree
Posted by Yi Li 3 years, 6 months ago
Eliminate cleanup code by using g_autofree.

Signed-off-by: Yi Li <yili@winhong.com>
---
 src/qemu/qemu_monitor_json.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6c763ecc12..4994ace071 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -455,8 +455,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);
@@ -464,8 +464,6 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd,
                        _("unexpected type returned by QEMU command '%s'"),
                        qemuMonitorJSONCommandName(cmd));
 
-        VIR_FREE(cmdstr);
-        VIR_FREE(retstr);
         return -1;
     }
 
-- 
2.25.3




Re: [PATCH v3] qemuMonitorJSONCheckReply: Use g_autofree
Posted by Ján Tomko 3 years, 5 months ago
On a Wednesday in 2020, Yi Li wrote:
>Eliminate cleanup code by using g_autofree.
>
>Signed-off-by: Yi Li <yili@winhong.com>
>---
> src/qemu/qemu_monitor_json.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

And pushed.

Jano