diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 3dd0665c3d35e5556e5504f11fea62a261fc978f..1b0a2cf9e3e1e0e55ba708df4275e8967b532ab0 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 9ebaf3c5a89339d0840283c24cd02a24c2378575..cf86a56af1ff1d0419d1827417c85fe7403d5746 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 43cd1a7175e630236b8aa89b4f612c5fcf0e8897..d582e7dbec1ae6af4815d942c08c845958a563b1 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 7ec42aa18903d115b2f3d7ffc2f906a2da9587b8..2d7fbf3eb4644b4f0f12447477b0f48e8025a11e 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 05d33a8ce2b6b2de07f6cc8476b778caf3d5ed52..e8dbd4d01a44632955c4277dba0f2a7e65d502bd 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,