Use g_autoptr() with the hash and remove the 'cleanup' label.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/conf/domain_conf.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4229add26d..f0300b870d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5823,20 +5823,19 @@ virDomainDefCollectBootOrder(virDomainDefPtr def G_GNUC_UNUSED,
static int
virDomainDefBootOrderPostParse(virDomainDefPtr def)
{
- GHashTable *bootHash = NULL;
- int ret = -1;
+ g_autoptr(GHashTable) bootHash = NULL;
if (!(bootHash = virHashNew(NULL)))
- goto cleanup;
+ return -1;
if (virDomainDeviceInfoIterate(def, virDomainDefCollectBootOrder, bootHash) < 0)
- goto cleanup;
+ return -1;
if (def->os.nBootDevs > 0 && virHashSize(bootHash) > 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("per-device boot elements cannot be used"
" together with os/boot elements"));
- goto cleanup;
+ return -1;
}
if (def->os.nBootDevs == 0 && virHashSize(bootHash) == 0) {
@@ -5844,11 +5843,7 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def)
def->os.bootDevs[0] = VIR_DOMAIN_BOOT_DISK;
}
- ret = 0;
-
- cleanup:
- virHashFree(bootHash);
- return ret;
+ return 0;
}
--
2.26.2