[libvirt] [PATCH 5/8] Introudce VIR_WARNINGS_NO_UNUSED_VALUE

Ján Tomko jtomko at redhat.com
Wed Jun 29 13:53:58 UTC 2016


Use it around virAtomicIntDecAndTest and virAtomicIntAdd which
give a warning when building with clang 3.8.
---
 src/internal.h       | 5 +++++
 src/util/viratomic.h | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/src/internal.h b/src/internal.h
index 0dc34c7..e4c20de 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -236,6 +236,10 @@
     _Pragma ("GCC diagnostic push") \
     _Pragma ("GCC diagnostic ignored \"-Wcast-align\"")
 
+#  define VIR_WARNINGS_NO_UNUSED_VALUE \
+    _Pragma ("GCC diagnostic push") \
+    _Pragma ("GCC diagnostic ignored \"-Wunused-value\"")
+
 #  if HAVE_SUGGEST_ATTRIBUTE_FORMAT
 #   define VIR_WARNINGS_NO_PRINTF \
     _Pragma ("GCC diagnostic push") \
@@ -259,6 +263,7 @@
 #  define VIR_WARNINGS_RESET \
     _Pragma ("GCC diagnostic pop")
 # else
+#  define VIR_WARNINGS_NO_UNUSED_VALUE
 #  define VIR_WARNINGS_NO_CAST_ALIGN
 #  define VIR_WARNINGS_NO_PRINTF
 #  define VIR_WARNINGS_NO_WLOGICALOP_EQUAL_EXPR
diff --git a/src/util/viratomic.h b/src/util/viratomic.h
index 4d7f7e5..a6f56ff 100644
--- a/src/util/viratomic.h
+++ b/src/util/viratomic.h
@@ -176,12 +176,17 @@ VIR_STATIC unsigned int virAtomicIntXor(volatile unsigned int *atomic,
             (void)(0 ? *(atomic) ^ *(atomic) : 0);                      \
             __sync_add_and_fetch((atomic), 1);                          \
         }))
+
+/* clang 3.8 complains about unused value here */
 #  define virAtomicIntDecAndTest(atomic)                                \
     (__extension__ ({                                                   \
             (void)verify_true(sizeof(*(atomic)) == sizeof(int));        \
             (void)(0 ? *(atomic) ^ *(atomic) : 0);                      \
+            VIR_WARNINGS_NO_UNUSED_VALUE                                \
             __sync_fetch_and_sub((atomic), 1) == 1;                     \
+            VIR_WARNINGS_RESET                                          \
         }))
+
 #  define virAtomicIntCompareExchange(atomic, oldval, newval)           \
     (__extension__ ({                                                   \
             (void)verify_true(sizeof(*(atomic)) == sizeof(int));        \
@@ -193,7 +198,9 @@ VIR_STATIC unsigned int virAtomicIntXor(volatile unsigned int *atomic,
     (__extension__ ({                                                   \
             (void)verify_true(sizeof(*(atomic)) == sizeof(int));        \
             (void)(0 ? *(atomic) ^ (val) : 0);                          \
+            VIR_WARNINGS_NO_UNUSED_VALUE                                \
             (int) __sync_fetch_and_add((atomic), (val));                \
+            VIR_WARNINGS_RESET                                          \
         }))
 #  define virAtomicIntAnd(atomic, val)                                  \
     (__extension__ ({                                                   \
-- 
2.7.3




More information about the libvir-list mailing list