[libvirt PATCH 01/11] glibcompat: Add wrapper for g_auto*

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

 



See comment for rationale.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/util/glibcompat.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
index 697687b967..fe495c5c32 100644
--- a/src/util/glibcompat.h
+++ b/src/util/glibcompat.h
@@ -86,3 +86,23 @@ char *vir_g_strdup_vprintf(const char *msg, va_list args)
 #define g_fsync vir_g_fsync
 
 void vir_g_source_unref(GSource *src, GMainContext *ctx);
+
+/*
+ * Clang falsely tags variable definitions as unused if the only access happens
+ * during the variables destruction at scope exit. See
+ * https://bugs.llvm.org/show_bug.cgi?id=3888 and
+ * https://bugs.llvm.org/show_bug.cgi?id=43482.
+ */
+#if defined(__clang__)
+# define vir_g_auto(X) g_auto(X) G_GNUC_UNUSED
+# define vir_g_autolist(X) g_autolist(X) G_GNUC_UNUSED
+# define vir_g_autoptr(X) g_autoptr(X) G_GNUC_UNUSED
+# define vir_g_autoqueue(X) g_autoqueue(X) G_GNUC_UNUSED
+# define vir_g_autoslist(X) g_autoslist(X) G_GNUC_UNUSED
+#else
+# define vir_g_auto(X) g_auto(X)
+# define vir_g_autolist(X) g_autolist(X)
+# define vir_g_autoptr(X) g_autoptr(X)
+# define vir_g_autoqueue(X) g_autoqueue(X)
+# define vir_g_autoslist(X) g_autoslist(X)
+#endif /* __clang__ */
-- 
2.31.1




[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