]> xenbits.xensource.com Git - libvirt.git/commitdiff
virZPCIDeviceAddressParseXML: Use virXMLProp*
authorTim Wiederhake <twiederh@redhat.com>
Wed, 21 Apr 2021 12:08:01 +0000 (14:08 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 21 Apr 2021 13:13:00 +0000 (15:13 +0200)
Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
src/conf/device_conf.c

index 6a4b14cfdae6c5158adf57eb27507662f2ad6064..9abbd5ebb70181967f6187719913c49d73754b8a 100644 (file)
@@ -52,32 +52,22 @@ static int
 virZPCIDeviceAddressParseXML(xmlNodePtr node,
                              virPCIDeviceAddress *addr)
 {
-    virZPCIDeviceAddress def = { .uid = { 0 }, .fid = { 0 } };
-    g_autofree char *uid = NULL;
-    g_autofree char *fid = NULL;
+    int retUid;
+    int retFid;
 
-    uid = virXMLPropString(node, "uid");
-    fid = virXMLPropString(node, "fid");
+    if ((retUid = virXMLPropUInt(node, "uid", 0, VIR_XML_PROP_NONE,
+                                 &addr->zpci.uid.value)) < 0)
+        return -1;
 
-    if (uid) {
-        if (virStrToLong_uip(uid, NULL, 0, &def.uid.value) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'uid' attribute"));
-            return -1;
-        }
-        def.uid.isSet = true;
-    }
+    if (retUid > 0)
+        addr->zpci.uid.isSet = true;
 
-    if (fid) {
-        if (virStrToLong_uip(fid, NULL, 0, &def.fid.value) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse <address> 'fid' attribute"));
-            return -1;
-        }
-        def.fid.isSet = true;
-    }
+    if ((retFid = virXMLPropUInt(node, "fid", 0, VIR_XML_PROP_NONE,
+                                 &addr->zpci.fid.value)) < 0)
+        return -1;
 
-    addr->zpci = def;
+    if (retFid > 0)
+        addr->zpci.fid.isSet = true;
 
     return 0;
 }