Document the return value and fix the error path of
lv_domain_get_tag
Signed-off-by: Francesco Romani <fromani@redhat.com>
+/*
+ * 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;
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 ret = -1;
+ int err;
err = xmlXPathRegisterNs(xpath_ctx,
(const xmlChar *)METADATA_VM_PARTITION_PREFIX,
err = xmlXPathRegisterNs(xpath_ctx,
(const xmlChar *)METADATA_VM_PARTITION_PREFIX,
* from now on there is no real error, it's ok if a domain
* doesn't have the metadata partition tag.
*/
* from now on there is no real error, it's ok if a domain
* doesn't have the metadata partition tag.
*/
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",
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);
/* 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);
if (xpath_obj)
xmlXPathFreeObject(xpath_obj);
}
static int is_known_tag(const char *dom_tag) {
}
static int is_known_tag(const char *dom_tag) {