[PATCH v1 19/20] node_device_udev: Add support for `g_autoptr` to `udevEventData`

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

 



Use this feature in `udevEventDataNew`.

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
---
 src/node_device/node_device_udev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 0b255952a9f9..cc8700fc4117 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -78,6 +78,7 @@ struct _udevEventData {
     /* Immutable pointer, self-locking APIs */
     virThreadPool *workerPool;
 };
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(udevEventData, virObjectUnref);
 
 static virClass *udevEventDataClass;
 
@@ -121,7 +122,7 @@ VIR_ONCE_GLOBAL_INIT(udevEventData);
 static udevEventData *
 udevEventDataNew(void)
 {
-    udevEventData *ret = NULL;
+    g_autoptr(udevEventData) ret = NULL;
 
     if (udevEventDataInitialize() < 0)
         return NULL;
@@ -129,19 +130,15 @@ udevEventDataNew(void)
     if (!(ret = virObjectLockableNew(udevEventDataClass)))
         return NULL;
 
-    if (virCondInit(&ret->udevThreadCond) < 0) {
-        virObjectUnref(ret);
+    if (virCondInit(&ret->udevThreadCond) < 0)
         return NULL;
-    }
 
-    if (virMutexInit(&ret->mdevctlLock) < 0) {
-        virObjectUnref(ret);
+    if (virMutexInit(&ret->mdevctlLock) < 0)
         return NULL;
-    }
 
     ret->mdevctlTimeout = -1;
     ret->watch = -1;
-    return ret;
+    return g_steal_pointer(&ret);
 }
 
 typedef enum {
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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