mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemuMonitorJSONBlockStatsUpdateCapacity: Refactor cleanup
Use automatic memory clearing for the temporary variable and remove the cleanup section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
65ff87c51c
commit
3beb56f3e8
@ -2660,9 +2660,8 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
|
|||||||
GHashTable *stats,
|
GHashTable *stats,
|
||||||
bool backingChain)
|
bool backingChain)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
virJSONValue *devices;
|
g_autoptr(virJSONValue) devices = NULL;
|
||||||
|
|
||||||
if (!(devices = qemuMonitorJSONQueryBlock(mon)))
|
if (!(devices = qemuMonitorJSONQueryBlock(mon)))
|
||||||
return -1;
|
return -1;
|
||||||
@ -2674,10 +2673,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
|
|||||||
const char *dev_name;
|
const char *dev_name;
|
||||||
|
|
||||||
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
|
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(dev_name = qemuMonitorJSONGetBlockDevDevice(dev)))
|
if (!(dev_name = qemuMonitorJSONGetBlockDevDevice(dev)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* drive may be empty */
|
/* drive may be empty */
|
||||||
if (!(inserted = virJSONValueObjectGetObject(dev, "inserted")) ||
|
if (!(inserted = virJSONValueObjectGetObject(dev, "inserted")) ||
|
||||||
@ -2687,14 +2686,10 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
|
|||||||
if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0,
|
if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0,
|
||||||
stats,
|
stats,
|
||||||
backingChain) < 0)
|
backingChain) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(devices);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user