From 5033e5efce82d53889f0cfaacc476ea6b8905d7b Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 5 Oct 2022 16:09:10 +0200 Subject: [PATCH] ppc64ModelParse: Switch to virXMLPropUInt from virXPathULongHex MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to do the extra XPath lookups and we can use the proper type right away. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- 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);