]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: savecookie: Remove virSaveCookieParseNode
authorPeter Krempa <pkrempa@redhat.com>
Fri, 23 Sep 2022 13:03:19 +0000 (15:03 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 6 Oct 2022 08:54:25 +0000 (10:54 +0200)
The function provided just checking of the root XML node name which can
be easily moved into the caller wich doesn't do that already and
checking of the pointers which is trivial. Remove the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/virsavecookie.c

index 5fc9ca06e1ca1a654c275e85b2e84269e445cdb6..3a6361e745d577b3f17723173bc4f84b9d04aae5 100644 (file)
 VIR_LOG_INIT("conf.savecookie");
 
 
-static int
-virSaveCookieParseNode(xmlXPathContextPtr ctxt,
-                       virObject **obj,
-                       virSaveCookieCallbacks *saveCookie)
-{
-    *obj = NULL;
-
-    if (!virXMLNodeNameEqual(ctxt->node, "cookie")) {
-        virReportError(VIR_ERR_XML_ERROR, "%s",
-                       _("XML does not contain expected 'cookie' element"));
-        return -1;
-    }
-
-    if (!saveCookie || !saveCookie->parse)
-        return 0;
-
-    return saveCookie->parse(ctxt, obj);
-}
-
-
 int
 virSaveCookieParse(xmlXPathContextPtr ctxt,
                    virObject **obj,
@@ -64,7 +44,10 @@ virSaveCookieParse(xmlXPathContextPtr ctxt,
     if (!(ctxt->node = virXPathNode("./cookie", ctxt)))
         return 0;
 
-    return virSaveCookieParseNode(ctxt, obj, saveCookie);
+    if (!saveCookie || !saveCookie->parse)
+        return 0;
+
+    return saveCookie->parse(ctxt, obj);
 }
 
 
@@ -78,13 +61,13 @@ virSaveCookieParseString(const char *xml,
 
     *obj = NULL;
 
-    if (!xml)
+    if (!xml || !saveCookie || !saveCookie->parse)
         return 0;
 
-    if (!(doc = virXMLParseStringCtxt(xml, _("(save cookie)"), &ctxt)))
+    if (!(doc = virXMLParse(NULL, xml, _("(save cookie)"), "cookie", &ctxt, NULL, false)))
         return -1;
 
-    return virSaveCookieParseNode(ctxt, obj, saveCookie);
+    return saveCookie->parse(ctxt, obj);
 }