1
0

qemuMonitorJSONBlockdevDel: Refactor cleanup

Use automatic variable freeing and get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Peter Krempa 2020-02-06 13:03:07 +01:00
parent 643294110c
commit a592d589aa

View File

@ -8843,9 +8843,8 @@ int
qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon, qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
const char *nodename) const char *nodename)
{ {
virJSONValuePtr cmd; g_autoptr(virJSONValue) cmd = NULL;
virJSONValuePtr reply = NULL; g_autoptr(virJSONValue) reply = NULL;
int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-del", if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-del",
"s:node-name", nodename, "s:node-name", nodename,
@ -8853,17 +8852,12 @@ qemuMonitorJSONBlockdevDel(qemuMonitorPtr mon,
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;
} }