[libvirt PATCH 08/14] virInterfaceDefParseIP: Simplify and cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/conf/interface_conf.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c
index f3fc47bd69..0b3e5716f3 100644
--- a/src/conf/interface_conf.c
+++ b/src/conf/interface_conf.c
@@ -252,24 +252,13 @@ virInterfaceDefParseDhcp(virInterfaceProtocolDef *def,
 
 static int
 virInterfaceDefParseIP(virInterfaceIPDef *def,
-                       xmlXPathContextPtr ctxt)
+                       xmlNodePtr node)
 {
-    int ret = 0;
-    char *tmp;
-    long l;
-
-    tmp = virXPathString("string(./@address)", ctxt);
-    def->address = tmp;
-    if (tmp != NULL) {
-        ret = virXPathLong("string(./@prefix)", ctxt, &l);
-        if (ret == 0) {
-            def->prefix = (int) l;
-        } else if (ret == -2) {
-            virReportError(VIR_ERR_XML_ERROR,
-                           "%s", _("Invalid ip address prefix value"));
-            return -1;
-        }
-    }
+    if ((def->address = virXMLPropString(node, "address")) == NULL)
+        return 0;
+
+    if (virXMLPropInt(node, "prefix", 0, VIR_XML_PROP_NONE, &def->prefix, 0) < 0)
+        return -1;
 
     return 0;
 }
@@ -309,8 +298,7 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDef *def,
 
         ip = g_new0(virInterfaceIPDef, 1);
 
-        ctxt->node = ipNodes[i];
-        if (virInterfaceDefParseIP(ip, ctxt) < 0) {
+        if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) {
             virInterfaceIPDefFree(ip);
             return -1;
         }
@@ -359,8 +347,7 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDef *def,
 
         ip = g_new0(virInterfaceIPDef, 1);
 
-        ctxt->node = ipNodes[i];
-        if (virInterfaceDefParseIP(ip, ctxt) < 0) {
+        if (virInterfaceDefParseIP(ip, ipNodes[i]) < 0) {
             virInterfaceIPDefFree(ip);
             return -1;
         }
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux