qemuMonitorJSONSetMigrationCapabilities: Refactor cleanup

Use automatic memory freeing 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:
Peter Krempa 2020-11-30 15:27:44 +01:00
parent d430b5ab31
commit 681006a14b

View File

@ -6974,27 +6974,21 @@ int
qemuMonitorJSONSetMigrationCapabilities(qemuMonitorPtr mon,
virJSONValuePtr *caps)
{
int ret = -1;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
if (!(cmd = qemuMonitorJSONMakeCommand("migrate-set-capabilities",
"a:capabilities", caps,
NULL);
if (!cmd)
goto cleanup;
NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
return 0;
}