From: Michal Privoznik Date: Fri, 22 Oct 2021 07:57:39 +0000 (+0200) Subject: qemu_monitor_json: Use g_autoptr() for virCPUData X-Git-Tag: v7.9.0-rc1~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c63955ab0f2de14a433a6f015c8aa0af0b52270b;p=thirdparty%2Flibvirt.git qemu_monitor_json: Use g_autoptr() for virCPUData We have g_autoptr() for virCPUData struct defined already. Let's use it in qemu_monitor_json.c and drop explicit free calls. Signed-off-by: Michal Privoznik Reviewed-by: Tim Wiederhake --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 655d2a022f..3d89afa6c6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7288,7 +7288,7 @@ qemuMonitorJSONParseCPUx86FeatureWord(virJSONValue *data, static virCPUData * qemuMonitorJSONParseCPUx86Features(virJSONValue *data) { - virCPUData *cpudata = NULL; + g_autoptr(virCPUData) cpudata = NULL; virCPUx86DataItem item = { 0 }; size_t i; @@ -7303,10 +7303,9 @@ qemuMonitorJSONParseCPUx86Features(virJSONValue *data) goto error; } - return cpudata; + return g_steal_pointer(&cpudata); error: - virCPUDataFree(cpudata); return NULL; } @@ -7418,8 +7417,8 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, virCPUData **data, virCPUData **disabled) { - virCPUData *cpuEnabled = NULL; - virCPUData *cpuDisabled = NULL; + g_autoptr(virCPUData) cpuEnabled = NULL; + g_autoptr(virCPUData) cpuDisabled = NULL; int rc; if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0) @@ -7436,14 +7435,12 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon, &cpuDisabled) < 0) goto error; - *data = cpuEnabled; + *data = g_steal_pointer(&cpuEnabled); if (disabled) - *disabled = cpuDisabled; + *disabled = g_steal_pointer(&cpuDisabled); return 0; error: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return -1; } @@ -7554,8 +7551,8 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, virCPUData **enabled, virCPUData **disabled) { - virCPUData *cpuEnabled = NULL; - virCPUData *cpuDisabled = NULL; + g_autoptr(virCPUData) cpuEnabled = NULL; + g_autoptr(virCPUData) cpuDisabled = NULL; int ret = -1; if (!(cpuEnabled = virCPUDataNew(arch)) || @@ -7576,8 +7573,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon, ret = 0; cleanup: - virCPUDataFree(cpuEnabled); - virCPUDataFree(cpuDisabled); return ret; }