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

Pavel Hrdina posted 2 patches 7 years, 1 month ago
[libvirt] [dbus PATCH 2/2] util: Introduce virtDBusUtilAutoLock
Posted by Pavel Hrdina 7 years, 1 month ago
clang 6.0.0 complains about unused variable if g_autoptr is used to
automatically unlock mutex.

Signed-off-by: Pavel Hrdina <phrdina@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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [dbus PATCH 2/2] util: Introduce virtDBusUtilAutoLock
Posted by Ján Tomko 7 years, 1 month ago
On Tue, Mar 27, 2018 at 06:44:42PM +0200, Pavel Hrdina wrote:
>clang 6.0.0 complains about unused variable if g_autoptr is used to

s/clang 6.0.0/Clang/

Also happens with 5.0.1 and the man page uses the Clang spelling,
so you're free to capitalize it at the beginning of the sentence.

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

ACK

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