mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
domain_conf: rewrite if else condition
This patch prevents nesting of if conditions and makes the code cleaner. Signed-off-by: Kristina Hanicova <khanicov@redhat.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
dc0ae3a50f
commit
3945327839
@ -5309,18 +5309,18 @@ virDomainDeviceAddressParseXML(xmlNodePtr address,
|
||||
{
|
||||
g_autofree char *type = virXMLPropString(address, "type");
|
||||
|
||||
if (type) {
|
||||
if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown address type '%s'"), type);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!type) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("No type specified for device address"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((info->type = virDomainDeviceAddressTypeFromString(type)) <= 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown address type '%s'"), type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch ((virDomainDeviceAddressType) info->type) {
|
||||
case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI:
|
||||
if (virPCIDeviceAddressParseXML(address, &info->addr.pci) < 0)
|
||||
@ -5996,20 +5996,19 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node,
|
||||
* <hostdev>. (the functions we're going to call expect address
|
||||
* type to already be known).
|
||||
*/
|
||||
if (type) {
|
||||
if ((def->source.subsys.type
|
||||
= virDomainHostdevSubsysTypeFromString(type)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown host device source address type '%s'"),
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!type) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("missing source address type"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((def->source.subsys.type = virDomainHostdevSubsysTypeFromString(type)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown host device source address type '%s'"),
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(sourcenode = virXPathNode("./source", ctxt))) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("Missing <source> element in hostdev device"));
|
||||
@ -6304,20 +6303,19 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_UNUSED,
|
||||
* <hostdev>. (the functions we're going to call expect address
|
||||
* type to already be known).
|
||||
*/
|
||||
if (type) {
|
||||
if ((def->source.caps.type
|
||||
= virDomainHostdevCapsTypeFromString(type)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown host device source address type '%s'"),
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
if (!type) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("missing source address type"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((def->source.caps.type = virDomainHostdevCapsTypeFromString(type)) < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown host device source address type '%s'"),
|
||||
type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!virXPathNode("./source", ctxt)) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("Missing <source> element in hostdev device"));
|
||||
|
Loading…
Reference in New Issue
Block a user