[libvirt PATCH RFC 15/19] util: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The VIR_XPATH_NODE_AUTORESTORE contains an ignore_value
statement to silence an unused variable warning on clang.

Use a pragma instead, which is not a statement.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/internal.h    | 5 +++++
 src/util/virxml.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/internal.h b/src/internal.h
index 3bab6b4bfe..3aa3c6ca67 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -189,6 +189,11 @@
      _Pragma ("GCC diagnostic push")
 #endif
 
+/* Where ignore_value cannot be used because it's a statement */
+#define VIR_WARNINGS_NO_UNUSED_VARIABLE \
+    _Pragma ("GCC diagnostic push") \
+    _Pragma ("GCC diagnostic ignored \"-Wunused-variable\"")
+
 #define VIR_WARNINGS_RESET \
     _Pragma ("GCC diagnostic pop")
 
diff --git a/src/util/virxml.h b/src/util/virxml.h
index 886d1e025f..0301f15308 100644
--- a/src/util/virxml.h
+++ b/src/util/virxml.h
@@ -241,9 +241,10 @@ G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(virXPathContextNodeSave, virXPathContextNodeRes
  * node pointer is reset to the original value when this macro was used.
  */
 #define VIR_XPATH_NODE_AUTORESTORE(_ctxt) \
+    VIR_WARNINGS_NO_UNUSED_VARIABLE \
     g_auto(virXPathContextNodeSave) _ctxt ## CtxtSave = { .ctxt = _ctxt,\
                                                           .node = _ctxt->node}; \
-    ignore_value(&_ctxt ## CtxtSave)
+    VIR_WARNINGS_RESET
 
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlDoc, xmlFreeDoc);
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(xmlXPathContext, xmlXPathFreeContext);
-- 
2.26.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux