Use a temporary auto-freed local variable to hold the hash table so that the cleanup section can be removed. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/conf/domain_validate.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index aab377fbbd..a9e4519b1a 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -1257,25 +1257,20 @@ static int virDomainDefValidateAliases(const virDomainDef *def, GHashTable **aliases) { - struct virDomainDefValidateAliasesData data; - int ret = -1; - /* We are not storing copies of aliases. Don't free them. */ - data.aliases = virHashNew(NULL); + g_autoptr(GHashTable) tmpaliases = virHashNew(NULL); + struct virDomainDefValidateAliasesData data = { .aliases = tmpaliases }; if (virDomainDeviceInfoIterateFlags((virDomainDef *) def, virDomainDeviceDefValidateAliasesIterator, DOMAIN_DEVICE_ITERATE_ALL_CONSOLES, &data) < 0) - goto cleanup; + return -1; if (aliases) - *aliases = g_steal_pointer(&data.aliases); + *aliases = g_steal_pointer(&tmpaliases); - ret = 0; - cleanup: - virHashFree(data.aliases); - return ret; + return 0; } -- 2.31.1