提交 52351030 编写于 作者: M Michal Privoznik

virxml: Don't overwrite ctxt->node

This reverts b897973f

Even though it may have been the case in the past, relative
XPaths don't overwrite the ctxt->node. Thus, there's no need to
save it.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 ec07aad8
......@@ -74,7 +74,6 @@ virXPathString(const char *xpath,
xmlXPathContextPtr ctxt)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
char *ret;
if ((ctxt == NULL) || (xpath == NULL)) {
......@@ -82,9 +81,7 @@ virXPathString(const char *xpath,
"%s", _("Invalid parameter to virXPathString()"));
return NULL;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj == NULL) || (obj->type != XPATH_STRING) ||
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
xmlXPathFreeObject(obj);
......@@ -152,16 +149,13 @@ virXPathNumber(const char *xpath,
double *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Invalid parameter to virXPathNumber()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj == NULL) || (obj->type != XPATH_NUMBER) ||
(isnan(obj->floatval))) {
xmlXPathFreeObject(obj);
......@@ -180,7 +174,6 @@ virXPathLongBase(const char *xpath,
long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
......@@ -188,9 +181,7 @@ virXPathLongBase(const char *xpath,
"%s", _("Invalid parameter to virXPathLong()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (virStrToLong_l((char *) obj->stringval, NULL, base, value) < 0)
......@@ -285,7 +276,6 @@ virXPathULongBase(const char *xpath,
unsigned long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
......@@ -293,9 +283,7 @@ virXPathULongBase(const char *xpath,
"%s", _("Invalid parameter to virXPathULong()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (virStrToLong_ul((char *) obj->stringval, NULL, base, value) < 0)
......@@ -401,7 +389,6 @@ virXPathULongLong(const char *xpath,
unsigned long long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
......@@ -409,9 +396,7 @@ virXPathULongLong(const char *xpath,
"%s", _("Invalid parameter to virXPathULong()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (virStrToLong_ull((char *) obj->stringval, NULL, 10, value) < 0)
......@@ -447,7 +432,6 @@ virXPathLongLong(const char *xpath,
long long *value)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret = 0;
if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
......@@ -455,9 +439,7 @@ virXPathLongLong(const char *xpath,
"%s", _("Invalid parameter to virXPathLongLong()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj != NULL) && (obj->type == XPATH_STRING) &&
(obj->stringval != NULL) && (obj->stringval[0] != 0)) {
if (virStrToLong_ll((char *) obj->stringval, NULL, 10, value) < 0)
......@@ -573,7 +555,6 @@ virXPathBoolean(const char *xpath,
xmlXPathContextPtr ctxt)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret;
if ((ctxt == NULL) || (xpath == NULL)) {
......@@ -581,9 +562,7 @@ virXPathBoolean(const char *xpath,
"%s", _("Invalid parameter to virXPathBoolean()"));
return -1;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj == NULL) || (obj->type != XPATH_BOOLEAN) ||
(obj->boolval < 0) || (obj->boolval > 1)) {
xmlXPathFreeObject(obj);
......@@ -610,7 +589,6 @@ virXPathNode(const char *xpath,
xmlXPathContextPtr ctxt)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
xmlNodePtr ret;
if ((ctxt == NULL) || (xpath == NULL)) {
......@@ -618,9 +596,7 @@ virXPathNode(const char *xpath,
"%s", _("Invalid parameter to virXPathNode()"));
return NULL;
}
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if ((obj == NULL) || (obj->type != XPATH_NODESET) ||
(obj->nodesetval == NULL) || (obj->nodesetval->nodeNr <= 0) ||
(obj->nodesetval->nodeTab == NULL)) {
......@@ -650,7 +626,6 @@ virXPathNodeSet(const char *xpath,
xmlNodePtr **list)
{
xmlXPathObjectPtr obj;
xmlNodePtr relnode;
int ret;
if ((ctxt == NULL) || (xpath == NULL)) {
......@@ -662,9 +637,7 @@ virXPathNodeSet(const char *xpath,
if (list != NULL)
*list = NULL;
relnode = ctxt->node;
obj = xmlXPathEval(BAD_CAST xpath, ctxt);
ctxt->node = relnode;
if (obj == NULL)
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册