On Thu, Aug 06, 2015 at 16:30:37 +0200, Andrea Bolognani wrote:
On Thu, 2015-08-06 at 13:53 +0200, Jiri Denemark wrote:
>
> > model = map->models;
> > while (model) {
> > - if (model->data->pvr == pvr)
> > - return model;
> > + for (i = 0; i < model->data->len; i++)
> > + if (model->data->pvr[i].value == pvr)
> > + return model;
>
> I think the for loop would deserve {} around its body.
Added.
> > +
> > + for (i = 0; i < n; i++) {
> > +
>
> Drop the empty line here.
Done.
> > + if (!(prop = virXMLPropString(nodes[i], "value"))) {
> > + virReportError(VIR_ERR_INTERNAL_ERROR,
> > + _("Missing PVR value in CPU model %s"),
> > + model->name);
> > + goto ignore;
> > + }
> > +
> > + if (virStrToLong_ul(prop, NULL, 16, &pvr) < 0) {
> > + virReportError(VIR_ERR_INTERNAL_ERROR,
> > + _("Invalid PVR value in CPU model %s"),
> > + model->name);
> > + goto ignore;
> > + }
>
> Any particular reason to replace virXPathULongHex with the above
> code?
Because I no longer have a single <pvr> element, but a number of
them, that I retrieved a few lines above using virXPathNodeSet().
I'm definitely no XPath expert, so if you're thinking of a way of
making this simpler feel free to share :)
Ah, right, you'd have to do something similar to this:
orig_node = ctxt->node;
for (...) {
virXPathULongHex("@value", ...);
}
ctxt->node = orig_node;
Jirka