render / rpms / libvirt

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