mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 22:55:23 +00:00
qemuMonitorJSON(Add|Del)Object: Refactor cleanup
Use 'g_autoptr' and remove the cleanup label and ret variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
0279754128
commit
9633dfbcfc
@ -4418,51 +4418,39 @@ int
|
|||||||
qemuMonitorJSONAddObject(qemuMonitorPtr mon,
|
qemuMonitorJSONAddObject(qemuMonitorPtr mon,
|
||||||
virJSONValuePtr props)
|
virJSONValuePtr props)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
virJSONValuePtr cmd;
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
|
|
||||||
if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props)))
|
if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props)))
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
ret = 0;
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int qemuMonitorJSONDelObject(qemuMonitorPtr mon,
|
|
||||||
const char *objalias)
|
|
||||||
{
|
|
||||||
int ret = -1;
|
|
||||||
virJSONValuePtr cmd;
|
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
|
|
||||||
cmd = qemuMonitorJSONMakeCommand("object-del",
|
|
||||||
"s:id", objalias,
|
|
||||||
NULL);
|
|
||||||
if (!cmd)
|
|
||||||
return -1;
|
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;
|
int
|
||||||
|
qemuMonitorJSONDelObject(qemuMonitorPtr mon,
|
||||||
|
const char *objalias)
|
||||||
|
{
|
||||||
|
g_autoptr(virJSONValue) cmd = NULL;
|
||||||
|
g_autoptr(virJSONValue) reply = NULL;
|
||||||
|
|
||||||
|
if (!(cmd = qemuMonitorJSONMakeCommand("object-del", "s:id", objalias, NULL)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user