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