]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
ppc64ModelParse: Switch to virXMLPropUInt from virXPathULongHex
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Oct 2022 14:09:10 +0000 (16:09 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Nov 2022 08:20:58 +0000 (09:20 +0100)
We don't need to do the extra XPath lookups and we can use the proper
type right away.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_ppc64.c

index 7da67ec94ade4cfe466ce53f2f323ecd97f83b38..30db99cca19521681a188b9980e170c65bb670c6 100644 (file)
@@ -305,7 +305,6 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
     g_autoptr(virCPUppc64Model) model = NULL;
     g_autofree xmlNodePtr *nodes = NULL;
     g_autofree char *vendor = NULL;
-    unsigned long pvr;
     size_t i;
     int n;
 
@@ -346,23 +345,13 @@ ppc64ModelParse(xmlXPathContextPtr ctxt,
     model->data.len = n;
 
     for (i = 0; i < n; i++) {
-        ctxt->node = nodes[i];
-
-        if (virXPathULongHex("string(./@value)", ctxt, &pvr) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Missing or invalid PVR value in CPU model %s"),
-                           model->name);
+        if (virXMLPropUInt(nodes[i], "value", 16, VIR_XML_PROP_REQUIRED,
+                           &model->data.pvr[i].value) < 0)
             return -1;
-        }
-        model->data.pvr[i].value = pvr;
 
-        if (virXPathULongHex("string(./@mask)", ctxt, &pvr) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Missing or invalid PVR mask in CPU model %s"),
-                           model->name);
+        if (virXMLPropUInt(nodes[i], "mask", 16, VIR_XML_PROP_REQUIRED,
+                           &model->data.pvr[i].mask) < 0)
             return -1;
-        }
-        model->data.pvr[i].mask = pvr;
     }
 
     VIR_APPEND_ELEMENT(map->models, map->nmodels, model);