summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4e8e1ad)
raw | patch | inline | side by side (parent: 4e8e1ad)
author | Francesco Romani <fromani@redhat.com> | |
Fri, 9 Dec 2016 15:22:03 +0000 (16:22 +0100) | ||
committer | Francesco Romani <fromani@redhat.com> | |
Fri, 9 Dec 2016 15:38:27 +0000 (16:38 +0100) |
Document the return value and fix the error path of
lv_domain_get_tag
Signed-off-by: Francesco Romani <fromani@redhat.com>
lv_domain_get_tag
Signed-off-by: Francesco Romani <fromani@redhat.com>
src/virt.c | patch | blob | history |
diff --git a/src/virt.c b/src/virt.c
index 86f83ae8e009c3fd31c76c0b5c3b1567911d1d9c..d3012d92069abf580861fce7119a7a064d35e6dc 100644 (file)
--- a/src/virt.c
+++ b/src/virt.c
return 0;
}
+/*
+ * returns 0 on success and <0 on error
+ */
static int lv_domain_get_tag(xmlXPathContextPtr xpath_ctx, const char *dom_name,
char *dom_tag) {
char xpath_str[BUFFER_MAX_LEN] = {'\0'};
xmlXPathObjectPtr xpath_obj = NULL;
xmlNodePtr xml_node = NULL;
- int err = -1;
+ int ret = -1;
+ int err;
err = xmlXPathRegisterNs(xpath_ctx,
(const xmlChar *)METADATA_VM_PARTITION_PREFIX,
@@ -776,8 +780,7 @@ static int lv_domain_get_tag(xmlXPathContextPtr xpath_ctx, const char *dom_name,
* from now on there is no real error, it's ok if a domain
* doesn't have the metadata partition tag.
*/
- err = 0;
-
+ ret = 0;
if (xpath_obj->nodesetval == NULL || xpath_obj->nodesetval->nodeNr != 1) {
DEBUG(PLUGIN_NAME " plugin: xmlXPathEval(%s) return nodeset size=%i "
"expected=1 on domain %s",
/* deregister to clean up */
err = xmlXPathRegisterNs(xpath_ctx,
(const xmlChar *)METADATA_VM_PARTITION_PREFIX, NULL);
-
+ if (err) {
+ /* we can't really recover here */
+ ERROR(PLUGIN_NAME
+ " plugin: deregistration of namespace %s failed for domain %s",
+ METADATA_VM_PARTITION_PREFIX, dom_name);
+ }
if (xpath_obj)
xmlXPathFreeObject(xpath_obj);
- return err;
+ return ret;
}
static int is_known_tag(const char *dom_tag) {