[PATCH 39/43] ppc64ModelParse: Switch to virXMLPropUInt from virXPathULongHex

Peter Krempa pkrempa at redhat.com
Mon Oct 24 14:14:44 UTC 2022


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 at redhat.com>
---
 src/cpu/cpu_ppc64.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 7da67ec94a..30db99cca1 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -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);
-- 
2.37.3



More information about the libvir-list mailing list