[libvirt] [PATCH] Conditionalize use of -Wno-suggest-attribute=format pragma

Many GCC versions don't understand -Wno-suggest-attribute=format so the pragma must only be used when supported --- m4/virt-compile-warnings.m4 | 6 ++++++ src/internal.h | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 532a777..b412a42 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -215,6 +215,12 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ ;; esac + case $WARN_CFLAGS in + *-Wsuggest-attribute=format*) + AC_DEFINE(HAVE_SUGGEST_ATTRIBUTE_FORMAT, [1], [Whether -Wsuggest-attribute=format works]) + ;; + esac + # Silence certain warnings in gnulib, and use improved glibc headers AC_DEFINE([lint], [1], [Define to 1 if the compiler is checking for lint.]) diff --git a/src/internal.h b/src/internal.h index 9855c49..4d473af 100644 --- a/src/internal.h +++ b/src/internal.h @@ -234,9 +234,15 @@ # define VIR_WARNINGS_NO_CAST_ALIGN \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wcast-align\"") -# define VIR_WARNINGS_NO_PRINTF \ + +# if HAVE_SUGGEST_ATTRIBUTE_FORMAT +# define VIR_WARNINGS_NO_PRINTF \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=format\"") +# else +# define VIR_WARNINGS_NO_PRINTF \ + _Pragma ("GCC diagnostic push") +# endif # define VIR_WARNINGS_RESET \ _Pragma ("GCC diagnostic pop") -- 2.1.0

On Fri, Jan 16, 2015 at 03:21:24PM +0000, Ian Campbell wrote:
On Fri, 2015-01-16 at 14:55 +0000, Daniel P. Berrange wrote:
Many GCC versions don't understand -Wno-suggest-attribute=format so the pragma must only be used when supported
That seems to have done the trick: Tested-by: Ian Campbell <ian.campbell@citrix.com>
Great, pushed that as a build-breaker fix. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (3)
-
Daniel P. Berrange
-
Guido Günther
-
Ian Campbell