[libvirt PATCH 05/21] util: Use glib memory functions in virLastErrorObject

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

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/util/virerror.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/util/virerror.c b/src/util/virerror.c
index 4ba99defbb..99a0855b51 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -237,15 +237,17 @@ virErrorCopyNew(virErrorPtr err)
 static virErrorPtr
 virLastErrorObject(void)
 {
-    virErrorPtr err;
+    g_autoptr(virError) err = NULL;
+
     err = virThreadLocalGet(&virLastErr);
-    if (!err) {
-        if (VIR_ALLOC_QUIET(err) < 0)
-            return NULL;
-        if (virThreadLocalSet(&virLastErr, err) < 0)
-            VIR_FREE(err);
-    }
-    return err;
+    if (err)
+        return g_steal_pointer(&err);
+
+    err = g_new0(virError, 1);
+    if (virThreadLocalSet(&virLastErr, err) < 0)
+        return NULL;
+
+    return g_steal_pointer(&err);
 }
 
 
-- 
2.26.2




[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