[PATCH 4/4] conf: Clean up and report error in virDomainGenerateMachineName

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/domain_conf.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3bef5bed3b4a..fffdeb353581 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -27151,25 +27151,23 @@ virDomainGenerateMachineName(const char *drivername,
                              const char *name,
                              bool privileged)
 {
-    char *machinename = NULL;
     char *username = NULL;
     virBuffer buf = VIR_BUFFER_INITIALIZER;
 
     if (privileged) {
         virBufferAsprintf(&buf, "%s-", drivername);
     } else {
-        if (!(username = virGetUserName(geteuid())))
-            goto cleanup;
-
+        if (!(username = virGetUserName(geteuid()))) {
+            virBufferFreeAndReset(&buf);
+            return NULL;
+        }
         virBufferAsprintf(&buf, "%s-%s-", username, drivername);
+        VIR_FREE(username);
     }
 
     virBufferAsprintf(&buf, "%d-", id);
     virDomainMachineNameAppendValid(&buf, name);
 
-    machinename = virBufferContentAndReset(&buf);
- cleanup:
-    VIR_FREE(username);
-
-    return machinename;
+    virBufferCheckError(&buf);
+    return virBufferContentAndReset(&buf);
 }
-- 
2.14.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux