mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuMonitorJSONAddDeviceProps: Refactor cleanup
Use automatic memory freeing and remove 'ret' variable and 'cleanup' label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2154718c29
commit
fbc088ab82
@ -4557,27 +4557,22 @@ int
|
|||||||
qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
|
qemuMonitorJSONAddDeviceProps(qemuMonitor *mon,
|
||||||
virJSONValue **props)
|
virJSONValue **props)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
virJSONValue *cmd = NULL;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValue *reply = NULL;
|
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL)))
|
if (!(cmd = qemuMonitorJSONMakeCommand("device_add", NULL)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virJSONValueObjectAppend(cmd, "arguments", props) < 0)
|
if (virJSONValueObjectAppend(cmd, "arguments", props) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user