[libvirt] [dbus PATCH 2/2] util: Introduce virtDBusUtilAutoLock

Pavel Hrdina phrdina at redhat.com
Tue Mar 27 16:44:42 UTC 2018


clang 6.0.0 complains about unused variable if g_autoptr is used to
automatically unlock mutex.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/connect.c | 2 +-
 src/util.h    | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/connect.c b/src/connect.c
index c6b85ce..2350736 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -56,7 +56,7 @@ gboolean
 virtDBusConnectOpen(virtDBusConnect *connect,
                     GError **error)
 {
-    g_autoptr(GMutexLocker) lock = g_mutex_locker_new(&connect->lock);
+    virtDBusUtilAutoLock lock = g_mutex_locker_new(&connect->lock);
 
     if (connect->connection) {
         if (virConnectIsAlive(connect->connection))
diff --git a/src/util.h b/src/util.h
index a34f863..4304bac 100644
--- a/src/util.h
+++ b/src/util.h
@@ -6,6 +6,8 @@
 
 #define VIRT_DBUS_ERROR virtDBusErrorQuark()
 
+#define virtDBusUtilAutoLock g_autoptr(GMutexLocker) G_GNUC_UNUSED
+
 typedef enum {
     VIRT_DBUS_ERROR_LIBVIRT,
     VIRT_DBUS_N_ERRORS /*< skip >*/
-- 
2.14.3




More information about the libvir-list mailing list