mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-26 14:03:49 +03:00
virDomainControllerDefParseXML: Remove explicit checks for negative value
Refactor all cases which use virXMLPropInt and then subsequently check that the parsed value is not '-1'/negative by using the VIR_XML_PROP_NONNEGATIVE flag for virXMLPropInt. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
318e5e3bac
commit
2486284c8c
@ -8263,28 +8263,16 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((rc = virXMLPropInt(node, "ports", 10, VIR_XML_PROP_NONE, &ports, -1)) < 0)
|
if (virXMLPropInt(node, "ports", 10, VIR_XML_PROP_NONNEGATIVE, &ports, -1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((rc == 1) && ports < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Invalid ports: %i"), ports);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
|
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: {
|
||||||
if ((rc = virXMLPropInt(node, "vectors", 10, VIR_XML_PROP_NONE,
|
if (virXMLPropInt(node, "vectors", 10, VIR_XML_PROP_NONNEGATIVE,
|
||||||
&def->opts.vioserial.vectors,
|
&def->opts.vioserial.vectors,
|
||||||
def->opts.vioserial.vectors)) < 0)
|
def->opts.vioserial.vectors) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((rc == 1) && def->opts.vioserial.vectors < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Invalid vectors: %i"),
|
|
||||||
def->opts.vioserial.vectors);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
def->opts.vioserial.ports = ports;
|
def->opts.vioserial.ports = ports;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -8345,29 +8333,15 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
|
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
|
||||||
if ((rc = virXMLPropInt(node, "maxGrantFrames", 10, VIR_XML_PROP_NONE,
|
if (virXMLPropInt(node, "maxGrantFrames", 10, VIR_XML_PROP_NONNEGATIVE,
|
||||||
&def->opts.xenbusopts.maxGrantFrames,
|
&def->opts.xenbusopts.maxGrantFrames,
|
||||||
def->opts.xenbusopts.maxGrantFrames)) < 0)
|
def->opts.xenbusopts.maxGrantFrames) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((rc == 1) && def->opts.xenbusopts.maxGrantFrames < 0) {
|
if (virXMLPropInt(node, "maxEventChannels", 10, VIR_XML_PROP_NONNEGATIVE,
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Invalid maxGrantFrames: %i"),
|
|
||||||
def->opts.xenbusopts.maxGrantFrames);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((rc = virXMLPropInt(node, "maxEventChannels", 10, VIR_XML_PROP_NONE,
|
|
||||||
&def->opts.xenbusopts.maxEventChannels,
|
&def->opts.xenbusopts.maxEventChannels,
|
||||||
def->opts.xenbusopts.maxEventChannels)) < 0)
|
def->opts.xenbusopts.maxEventChannels) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if ((rc == 1) && def->opts.xenbusopts.maxEventChannels < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Invalid maxEventChannels: %i"),
|
|
||||||
def->opts.xenbusopts.maxEventChannels);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user