]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: xml: use pragma in VIR_XPATH_NODE_AUTORESTORE
authorJán Tomko <jtomko@redhat.com>
Tue, 28 Jul 2020 19:47:29 +0000 (21:47 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 25 Aug 2020 17:03:12 +0000 (19:03 +0200)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/internal.h
src/util/virxml.h

index 3bab6b4bfe072e3a75a84b4f351c145f9a790c65..3aa3c6ca677e1f163af92996a75ecd239f2f62e2 100644 (file)
      _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")
 
index 886d1e025f4a3f74b7b9c4c1eb52031593ac4108..0301f1530873856b29ae1ffde8e31a262bcd6009 100644 (file)
@@ -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);