mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
qemu: monitor: Refactor cleanup in qemuMonitorJSONGetOneBlockStatsInfo
Use VIR_AUTOFREE and get rid of the cleanup label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
280e70ca8d
commit
121911c853
@ -2601,17 +2601,16 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
|
||||
virHashTablePtr hash,
|
||||
bool backingChain)
|
||||
{
|
||||
qemuBlockStatsPtr bstats = NULL;
|
||||
int ret = -1;
|
||||
VIR_AUTOFREE(qemuBlockStatsPtr) bstats = NULL;
|
||||
int nstats = 0;
|
||||
const char *qdevname = NULL;
|
||||
const char *nodename = NULL;
|
||||
char *devicename = NULL;
|
||||
VIR_AUTOFREE(char *) devicename = NULL;
|
||||
virJSONValuePtr backing;
|
||||
|
||||
if (dev_name &&
|
||||
!(devicename = qemuDomainStorageAlias(dev_name, depth)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
qdevname = virJSONValueObjectGetString(dev, "qdev");
|
||||
nodename = virJSONValueObjectGetString(dev, "node-name");
|
||||
@ -2619,35 +2618,31 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
|
||||
if (!devicename && !qdevname && !nodename) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("blockstats device entry was not in expected format"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(bstats = qemuMonitorJSONBlockStatsCollectData(dev, &nstats)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (devicename &&
|
||||
qemuMonitorJSONAddOneBlockStatsInfo(bstats, devicename, hash) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (qdevname && STRNEQ_NULLABLE(qdevname, devicename) &&
|
||||
qemuMonitorJSONAddOneBlockStatsInfo(bstats, qdevname, hash) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (nodename &&
|
||||
qemuMonitorJSONAddOneBlockStatsInfo(bstats, nodename, hash) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (backingChain &&
|
||||
(backing = virJSONValueObjectGetObject(dev, "backing")) &&
|
||||
qemuMonitorJSONGetOneBlockStatsInfo(backing, dev_name, depth + 1,
|
||||
hash, true) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = nstats;
|
||||
cleanup:
|
||||
VIR_FREE(bstats);
|
||||
VIR_FREE(devicename);
|
||||
return ret;
|
||||
return nstats;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user