qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/3] qemu/compiler: Simplify as all compilers support attribu


From: Daniel P . Berrangé
Subject: Re: [PATCH 1/3] qemu/compiler: Simplify as all compilers support attribute 'gnu_printf'
Date: Mon, 28 Sep 2020 15:04:48 +0100
User-agent: Mutt/1.14.6 (2020-07-11)

On Mon, Sep 28, 2020 at 02:58:57PM +0200, Philippe Mathieu-Daudé wrote:
> Since commit efc6c070aca ("configure: Add a test for the minimum
> compiler version") the minimum compiler version required for GCC
> is 4.8, which supports the gnu_printf attribute.
> 
> We can safely remove the code introduced in commit 9c9e7d51bf0
> ("Move macros GCC_ATTR and GCC_FMT_ATTR to common header file").
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  include/qemu/compiler.h | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
> index c76281f3540..207e3bd4feb 100644
> --- a/include/qemu/compiler.h
> +++ b/include/qemu/compiler.h
> @@ -104,17 +104,14 @@
>                                     sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
>  
>  #if defined __GNUC__
> -# if !QEMU_GNUC_PREREQ(4, 4)
> -   /* gcc versions before 4.4.x don't support gnu_printf, so use printf. */
> -#  define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
> -# else
> -   /* Use gnu_printf when supported (qemu uses standard format strings). */
> -#  define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> -#  if defined(_WIN32)
> -    /* Map __printf__ to __gnu_printf__ because we want standard format 
> strings
> -     * even when MinGW or GLib include files use __printf__. */
> -#   define __printf__ __gnu_printf__
> -#  endif
> +  /* Use gnu_printf when supported (qemu uses standard format strings). */
> +# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
> +# if defined(_WIN32)
> +   /*
> +    * Map __printf__ to __gnu_printf__ because we want standard format 
> strings
> +    * even when MinGW or GLib include files use __printf__.
> +    */
> +#  define __printf__ __gnu_printf__
>  # endif
>  #else
>  #define GCC_FMT_ATTR(n, m)

I think this can be simplified even more by using GLib's macros

  #define GCC_FMT_ATTR(n, m)  G_GNUC_PRINTF(n, m)

and ideally we'd then convert all crrent usage to the latter and
drop GCC_FMT_ATTR.

https://developer.gnome.org/glib/2.64/glib-Miscellaneous-Macros.html

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 :|




reply via email to

[Prev in Thread] Current Thread [Next in Thread]