From ed3cc76b486747b897f9a96be3954014f6247ac6 Mon Sep 17 00:00:00 2001 From: Yi Li Date: Thu, 5 Nov 2020 16:37:46 +0800 Subject: [PATCH] virsh-domain: Remove unused virshNodeIsSuperset The function is marked as unused. Remove it from the tree until a new use case can be found. Unused since: 38cc07b7bc76d3ffdf55deb65f4acf11c0fa9014 Signed-off-by: Yi Li Reviewed-by: Erik Skultety --- tools/virsh-domain.c | 115 ------------------------------------------- 1 file changed, 115 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index ef347585e8..1ae936c6b2 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11933,121 +11933,6 @@ cmdDomHostname(vshControl *ctl, const vshCmd *cmd) return true; } -/** - * Check if n1 is superset of n2, meaning n1 contains all elements and - * attributes as n2 at least. Including children. - * @n1 first node - * @n2 second node - * returns true in case n1 covers n2, false otherwise. - */ -G_GNUC_UNUSED -static bool -virshNodeIsSuperset(xmlNodePtr n1, xmlNodePtr n2) -{ - xmlNodePtr child1, child2; - xmlAttrPtr attr; - char *prop1, *prop2; - bool found; - bool visited; - bool ret = false; - long n1_child_size, n2_child_size, n1_iter; - virBitmapPtr bitmap; - - if (!n1 && !n2) - return true; - - if (!n1 || !n2) - return false; - - if (!xmlStrEqual(n1->name, n2->name)) - return false; - - /* Iterate over n2 attributes and check if n1 contains them */ - attr = n2->properties; - while (attr) { - if (attr->type == XML_ATTRIBUTE_NODE) { - prop1 = virXMLPropString(n1, (const char *) attr->name); - prop2 = virXMLPropString(n2, (const char *) attr->name); - if (STRNEQ_NULLABLE(prop1, prop2)) { - xmlFree(prop1); - xmlFree(prop2); - return false; - } - xmlFree(prop1); - xmlFree(prop2); - } - attr = attr->next; - } - - n1_child_size = virXMLChildElementCount(n1); - n2_child_size = virXMLChildElementCount(n2); - if (n1_child_size < 0 || n2_child_size < 0 || - n1_child_size < n2_child_size) - return false; - - if (n1_child_size == 0 && n2_child_size == 0) - return true; - - bitmap = virBitmapNew(n1_child_size); - - child2 = n2->children; - while (child2) { - if (child2->type != XML_ELEMENT_NODE) { - child2 = child2->next; - continue; - } - - child1 = n1->children; - n1_iter = 0; - found = false; - while (child1) { - if (child1->type != XML_ELEMENT_NODE) { - child1 = child1->next; - continue; - } - - if (virBitmapGetBit(bitmap, n1_iter, &visited) < 0) { - vshError(NULL, "%s", _("Bad child elements counting.")); - goto cleanup; - } - - if (visited) { - child1 = child1->next; - n1_iter++; - continue; - } - - if (xmlStrEqual(child1->name, child2->name)) { - found = true; - if (virBitmapSetBit(bitmap, n1_iter) < 0) { - vshError(NULL, "%s", _("Bad child elements counting.")); - goto cleanup; - } - - if (!virshNodeIsSuperset(child1, child2)) - goto cleanup; - - break; - } - - child1 = child1->next; - n1_iter++; - } - - if (!found) - goto cleanup; - - child2 = child2->next; - } - - ret = true; - - cleanup: - virBitmapFree(bitmap); - return ret; -} - - /* * "detach-device" command */