mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-25 14:05:18 +00:00
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 <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
3dfc47c1fd
commit
c63955ab0f
@ -7288,7 +7288,7 @@ qemuMonitorJSONParseCPUx86FeatureWord(virJSONValue *data,
|
|||||||
static virCPUData *
|
static virCPUData *
|
||||||
qemuMonitorJSONParseCPUx86Features(virJSONValue *data)
|
qemuMonitorJSONParseCPUx86Features(virJSONValue *data)
|
||||||
{
|
{
|
||||||
virCPUData *cpudata = NULL;
|
g_autoptr(virCPUData) cpudata = NULL;
|
||||||
virCPUx86DataItem item = { 0 };
|
virCPUx86DataItem item = { 0 };
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
@ -7303,10 +7303,9 @@ qemuMonitorJSONParseCPUx86Features(virJSONValue *data)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cpudata;
|
return g_steal_pointer(&cpudata);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virCPUDataFree(cpudata);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7418,8 +7417,8 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon,
|
|||||||
virCPUData **data,
|
virCPUData **data,
|
||||||
virCPUData **disabled)
|
virCPUData **disabled)
|
||||||
{
|
{
|
||||||
virCPUData *cpuEnabled = NULL;
|
g_autoptr(virCPUData) cpuEnabled = NULL;
|
||||||
virCPUData *cpuDisabled = NULL;
|
g_autoptr(virCPUData) cpuDisabled = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0)
|
if ((rc = qemuMonitorJSONCheckCPUx86(mon)) < 0)
|
||||||
@ -7436,14 +7435,12 @@ qemuMonitorJSONGetGuestCPUx86(qemuMonitor *mon,
|
|||||||
&cpuDisabled) < 0)
|
&cpuDisabled) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
*data = cpuEnabled;
|
*data = g_steal_pointer(&cpuEnabled);
|
||||||
if (disabled)
|
if (disabled)
|
||||||
*disabled = cpuDisabled;
|
*disabled = g_steal_pointer(&cpuDisabled);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
virCPUDataFree(cpuEnabled);
|
|
||||||
virCPUDataFree(cpuDisabled);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7554,8 +7551,8 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
|
|||||||
virCPUData **enabled,
|
virCPUData **enabled,
|
||||||
virCPUData **disabled)
|
virCPUData **disabled)
|
||||||
{
|
{
|
||||||
virCPUData *cpuEnabled = NULL;
|
g_autoptr(virCPUData) cpuEnabled = NULL;
|
||||||
virCPUData *cpuDisabled = NULL;
|
g_autoptr(virCPUData) cpuDisabled = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(cpuEnabled = virCPUDataNew(arch)) ||
|
if (!(cpuEnabled = virCPUDataNew(arch)) ||
|
||||||
@ -7576,8 +7573,6 @@ qemuMonitorJSONGetGuestCPU(qemuMonitor *mon,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCPUDataFree(cpuEnabled);
|
|
||||||
virCPUDataFree(cpuDisabled);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user