From f09302215540934508e4debb89ecf97f7101e905 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Fri, 23 Sep 2022 15:03:19 +0200 Subject: [PATCH] conf: savecookie: Remove virSaveCookieParseNode MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- src/conf/virsavecookie.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c index 5fc9ca06e1..3a6361e745 100644 --- a/src/conf/virsavecookie.c +++ b/src/conf/virsavecookie.c @@ -32,26 +32,6 @@ 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); } -- 2.47.2