qemuMonitorJSONBlockStatsUpdateCapacityOne: 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:
Peter Krempa 2021-10-19 14:48:16 +02:00
parent 3beb56f3e8
commit c93bf61647

View File

@ -2631,13 +2631,12 @@ qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValue *image,
GHashTable *stats,
bool backingChain)
{
int ret = -1;
char *entry_name = qemuDomainStorageAlias(dev_name, depth);
g_autofree char *entry_name = qemuDomainStorageAlias(dev_name, depth);
virJSONValue *backing;
if (qemuMonitorJSONBlockStatsUpdateCapacityData(image, entry_name,
stats, NULL) < 0)
goto cleanup;
return -1;
if (backingChain &&
(backing = virJSONValueObjectGetObject(image, "backing-image")) &&
@ -2646,12 +2645,9 @@ qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValue *image,
depth + 1,
stats,
true) < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
VIR_FREE(entry_name);
return ret;
return 0;
}