Friday, January 27, 2023

sysutils/libvirt and clang 15 (was: Re: amd64-clang bulk build report (llvm 15))

On Sun, Jan 08 2023, Jeremie Courreges-Anglas <jca@wxcvbn.org> wrote:

[...]

>> https://wxcvbn.org/~jca/build-failures/amd64-clang/2023-01-03/sysutils/libvirt.txt
> ../libvirt-8.10.0/src/remote/remote_daemon_stream.c:458:5: error: incompatible integer to pointer conversion assigning to 'virMutex *' (aka 'struct virMutex *') from 'int' [-Wint-conversion]
> VIR_WITH_MUTEX_LOCK_GUARD(&priv->lock) {
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think this one is a false positive. virLockGuardUnlock() returns
void, not int; and the resulting type of an a, b sequence is the type of
b. Or maybe I'm missing something... Nevertheless, the code is IMO
weirdly written and easier to understand as proposed in the diff below,
so upstream shouldn't object much.

ok?


Index: Makefile
===================================================================
RCS file: /home/cvs/ports/sysutils/libvirt/Makefile,v
retrieving revision 1.104
diff -u -p -r1.104 Makefile
--- Makefile 17 Jan 2023 10:12:52 -0000 1.104
+++ Makefile 27 Jan 2023 17:16:42 -0000
@@ -1,6 +1,7 @@
COMMENT= tool/library for managing platform virtualization

DISTNAME= libvirt-9.0.0
+REVISION= 0

CATEGORIES= sysutils devel emulators

Index: patches/patch-src_util_virobject_h
===================================================================
RCS file: patches/patch-src_util_virobject_h
diff -N patches/patch-src_util_virobject_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_util_virobject_h 11 Jan 2023 19:48:16 -0000
@@ -0,0 +1,14 @@
+Work around bogus clang -Wint-conversion warning.
+
+Index: src/util/virobject.h
+--- src/util/virobject.h.orig
++++ src/util/virobject.h
+@@ -145,7 +145,7 @@ virObjectListFreeCount(void *list,
+
+ #define VIR_WITH_OBJECT_LOCK_GUARD_(o, name) \
+ for (g_auto(virLockGuard) name = virObjectLockGuard(o); name.mutex; \
+- name.mutex = (virLockGuardUnlock(&name), NULL))
++ virLockGuardUnlock(&name), name.mutex = NULL)
+
+ /**
+ * VIR_WITH_OBJECT_LOCK_GUARD:
Index: patches/patch-src_util_virthread_h
===================================================================
RCS file: patches/patch-src_util_virthread_h
diff -N patches/patch-src_util_virthread_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_util_virthread_h 11 Jan 2023 19:48:29 -0000
@@ -0,0 +1,14 @@
+Work around bogus clang -Wint-conversion warning.
+
+Index: src/util/virthread.h
+--- src/util/virthread.h.orig
++++ src/util/virthread.h
+@@ -212,7 +212,7 @@ int virThreadLocalSet(virThreadLocal *l, void*) G_GNUC
+
+ #define VIR_WITH_MUTEX_LOCK_GUARD_(m, name) \
+ for (g_auto(virLockGuard) name = virLockGuardLock(m); name.mutex; \
+- name.mutex = (virLockGuardUnlock(&name), NULL))
++ virLockGuardUnlock(&name), name.mutex = NULL)
+ /**
+ * VIR_WITH_MUTEX_LOCK_GUARD:
+ *

--
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE

No comments:

Post a Comment