From: Pavel Hrdina Date: Sun, 10 Apr 2016 18:21:13 +0200 Subject: [PATCH] build: cleanup GCC < 4.6 -Wlogical-op workaround Signed-off-by: Pavel Hrdina (cherry picked from commit 7fb81831fc497aa4a34fdfc036be9c9ae4401084) --- m4/virt-compile-warnings.m4 | 2 +- src/internal.h | 10 ++++++++++ src/util/virbuffer.c | 11 +++-------- src/util/virstring.c | 9 +-------- src/util/virsysinfo.c | 13 ++----------- 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 3dd0665..1b0a2cf 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -236,7 +236,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ if test "$gl_cv_warn_c__Wlogical_op" = yes && test "$lv_cv_gcc_wlogical_op_broken" = yes; then - AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP], 1, + AC_DEFINE_UNQUOTED([BROKEN_GCC_WLOGICALOP_STRCHR], 1, [Define to 1 if gcc -Wlogical-op reports false positives on strchr]) fi ]) diff --git a/src/internal.h b/src/internal.h index db26fb0..35cc6d4 100644 --- a/src/internal.h +++ b/src/internal.h @@ -253,6 +253,16 @@ # define VIR_WARNINGS_RESET # endif +/* Workaround bogus GCC < 4.6 that produces false -Wlogical-op warnings for + * strchr(). Those old GCCs don't support push/pop. */ +# if BROKEN_GCC_WLOGICALOP_STRCHR +# define VIR_WARNINGS_NO_WLOGICALOP_STRCHR \ + _Pragma ("GCC diagnostic ignored \"-Wlogical-op\"") +# else +# define VIR_WARNINGS_NO_WLOGICALOP_STRCHR +# endif + + /* * Use this when passing possibly-NULL strings to printf-a-likes. */ diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 43cd1a7..d582e7d 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -417,14 +417,9 @@ virBufferVasprintf(virBufferPtr buf, const char *format, va_list argptr) buf->use += count; } -/* Work around spurious strchr() diagnostics given by -Wlogical-op - * for gcc < 4.6. Doing it via a local pragma keeps the damage - * smaller than disabling it on the package level. Unfortunately, the - * affected GCCs don't allow diagnostic push/pop which would have - * further reduced the impact. */ -#if BROKEN_GCC_WLOGICALOP -# pragma GCC diagnostic ignored "-Wlogical-op" -#endif + +VIR_WARNINGS_NO_WLOGICALOP_STRCHR + /** * virBufferEscapeString: diff --git a/src/util/virstring.c b/src/util/virstring.c index 7ec42aa..2d7fbf3 100644 --- a/src/util/virstring.c +++ b/src/util/virstring.c @@ -989,14 +989,7 @@ virStringHasControlChars(const char *str) } -/* Work around spurious strchr() diagnostics given by -Wlogical-op - * for gcc < 4.6. Doing it via a local pragma keeps the damage - * smaller than disabling it on the package level. Unfortunately, the - * affected GCCs don't allow diagnostic push/pop which would have - * further reduced the impact. */ -#if BROKEN_GCC_WLOGICALOP -# pragma GCC diagnostic ignored "-Wlogical-op" -#endif +VIR_WARNINGS_NO_WLOGICALOP_STRCHR /** diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 05d33a8..e8dbd4d 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -428,17 +428,8 @@ virSysinfoRead(void) #elif defined(__s390__) || defined(__s390x__) -/* - we need to ignore warnings about strchr caused by -Wlogical-op - for some GCC versions. - Doing it via a local pragma keeps the damage smaller than - disabling it on the package level. - Unfortunately, the affected GCCs don't allow diagnostic push/pop - which would have further reduced the impact. - */ -# if BROKEN_GCC_WLOGICALOP -# pragma GCC diagnostic ignored "-Wlogical-op" -# endif + +VIR_WARNINGS_NO_WLOGICALOP_STRCHR static char * virSysinfoParseDelimited(const char *base, const char *name, char **value,