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

Ján Tomko jtomko at redhat.com
Wed Aug 25 15:13:38 UTC 2021


On a Wednesday in 2021, Tim Wiederhake wrote:
>See comment for rationale.
>

Missing commit message ;)

>Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
>---
> 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

In Clang's defense, the warning is legitimate and has caught many unused
variables.

It's our usage that is weird here.

>+ * 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

These are not needed since in all cases, the G_GNUC_UNUSED can be used
unconditionally for both gcc and CLang in the respective macros.

Jano

>+#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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210825/19cdf78c/attachment-0001.sig>


More information about the libvir-list mailing list