Re: [libvirt PATCH v2 01/12] glibcompat: Add G_GNUC_UNUSED to g_auto* definitions for clang

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

 



On Fri, Sep 10, 2021 at 12:45:43PM +0200, Tim Wiederhake wrote:
> Workaround for a bug in clang. Clang emits an unused-variable warning
> if the variable is only accessed on scope exit by a destructor function.
> Note that gcc does not exhibit this behavior.
> 
> See https://bugs.llvm.org/show_bug.cgi?id=3888 and
> https://bugs.llvm.org/show_bug.cgi?id=43482.
> 
> Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
> ---
>  src/util/glibcompat.h | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/src/util/glibcompat.h b/src/util/glibcompat.h
> index 697687b967..ea486e32d5 100644
> --- a/src/util/glibcompat.h
> +++ b/src/util/glibcompat.h
> @@ -86,3 +86,22 @@ 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);
> +
> +/*
> + * Workaround for a bug in clang. Clang emits an unused-variable warning if the
> + * variable is only accessed on scope exit by a destructor function. See
> + * https://bugs.llvm.org/show_bug.cgi?id=3888 and
> + * https://bugs.llvm.org/show_bug.cgi?id=43482.
> + */
> +#if defined(__clang__)
> +# undef g_autoptr
> +# define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName) G_GNUC_UNUSED
> +# undef g_autolist
> +# define g_autolist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_LIST_TYPENAME(TypeName) G_GNUC_UNUSED
> +# undef g_autoslist
> +# define g_autoslist(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_SLIST_TYPENAME(TypeName) G_GNUC_UNUSED
> +# undef g_autoqueue
> +# define g_autoqueue(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_QUEUE_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_QUEUE_TYPENAME(TypeName) G_GNUC_UNUSED
> +# undef g_auto
> +# define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName G_GNUC_UNUSED
> +#endif /* __clang__ */

This patch should not be needed anymore afaik since we addressed the
problems that were triggering clang.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




[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