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>
GHashTable *stats,
bool backingChain)
{
- int ret = -1;
size_t i;
- virJSONValue *devices;
+ g_autoptr(virJSONValue) devices = NULL;
if (!(devices = qemuMonitorJSONQueryBlock(mon)))
return -1;
const char *dev_name;
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
- goto cleanup;
+ return -1;
if (!(dev_name = qemuMonitorJSONGetBlockDevDevice(dev)))
- goto cleanup;
+ return -1;
/* drive may be empty */
if (!(inserted = virJSONValueObjectGetObject(dev, "inserted")) ||
if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0,
stats,
backingChain) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- virJSONValueFree(devices);
- return ret;
+ return 0;
}