]> xenbits.xensource.com Git - libvirt.git/commitdiff
virQEMUDriverConfigLoadSWTPMEntry: use VIR_AUTOFREE
authorJán Tomko <jtomko@redhat.com>
Mon, 21 Jan 2019 13:48:18 +0000 (14:48 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 21 Jan 2019 16:14:29 +0000 (17:14 +0100)
Switch the function to use VIR_AUTOFREE and VIR_AUTOPTR macros
to get rid of the cleanup section.

Requested-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/qemu/qemu_conf.c

index 37f09b8e80a452148ec6ce6c796069a19bde760f..2baf13b1c7038595b0d9930ad7d63914fc76cb7c 100644 (file)
@@ -984,24 +984,20 @@ static int
 virQEMUDriverConfigLoadSWTPMEntry(virQEMUDriverConfigPtr cfg,
                                   virConfPtr conf)
 {
-    char *swtpm_user = NULL, *swtpm_group = NULL;
-    int ret = -1;
+    VIR_AUTOFREE(char *) swtpm_user = NULL;
+    VIR_AUTOFREE(char *) swtpm_group = NULL;
 
     if (virConfGetValueString(conf, "swtpm_user", &swtpm_user) < 0)
-        goto cleanup;
+        return -1;
     if (swtpm_user && virGetUserID(swtpm_user, &cfg->swtpm_user) < 0)
-        goto cleanup;
+        return -1;
 
     if (virConfGetValueString(conf, "swtpm_group", &swtpm_group) < 0)
-        goto cleanup;
+        return -1;
     if (swtpm_group && virGetGroupID(swtpm_group, &cfg->swtpm_group) < 0)
-        goto cleanup;
+        return -1;
 
-    ret = 0;
- cleanup:
-    VIR_FREE(swtpm_user);
-    VIR_FREE(swtpm_group);
-    return ret;
+    return 0;
 }