From bfbbc49638630e09766bc601c95d14a0155d79a8 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Fri, 13 Jan 2012 14:39:26 +1100 Subject: [PATCH] conf: Remove do-nothing validation functions There are three address validation routines that do nothing: virDomainDeviceDriveAddressIsValid() virDomainDeviceUSBAddressIsValid() virDomainDeviceVirtioSerialAddressIsValid() Remove them, and replace their call sites with "1" which is what they currently return. In some cases this means we can remove an entire if block. Signed-off-by: Michael Ellerman --- src/conf/domain_conf.c | 36 ++---------------------------------- src/conf/domain_conf.h | 3 --- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index cf12606bbe..6c42f36f1e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1766,10 +1766,10 @@ int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, return virDomainDevicePCIAddressIsValid(&info->addr.pci); case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE: - return virDomainDeviceDriveAddressIsValid(&info->addr.drive); + return 1; case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - return virDomainDeviceUSBAddressIsValid(&info->addr.usb); + return 1; } return 0; @@ -1785,24 +1785,6 @@ int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr) } -int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr ATTRIBUTE_UNUSED) -{ - /*return addr->controller || addr->bus || addr->unit;*/ - return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */ -} - -int virDomainDeviceUSBAddressIsValid(virDomainDeviceUSBAddressPtr addr ATTRIBUTE_UNUSED) -{ - return 1; /* FIXME.. any successfully parsed addr is valid */ -} - -int virDomainDeviceVirtioSerialAddressIsValid( - virDomainDeviceVirtioSerialAddressPtr addr ATTRIBUTE_UNUSED) -{ - return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */ -} - - static int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info, unsigned int flags) { @@ -1813,7 +1795,6 @@ virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info, unsigned int flags) return 0; } - void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { VIR_FREE(info->alias); @@ -2098,12 +2079,6 @@ virDomainDeviceDriveAddressParseXML(xmlNodePtr node, goto cleanup; } - if (!virDomainDeviceDriveAddressIsValid(addr)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Insufficient specification for drive address")); - goto cleanup; - } - ret = 0; cleanup: @@ -2150,13 +2125,6 @@ virDomainDeviceVirtioSerialAddressParseXML( goto cleanup; } - if (!virDomainDeviceVirtioSerialAddressIsValid(addr)) { - virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Insufficient specification for " - "virtio serial address")); - goto cleanup; - } - ret = 0; cleanup: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 20383c2250..7c7e93b102 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1713,9 +1713,6 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def); int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int type); int virDomainDevicePCIAddressIsValid(virDomainDevicePCIAddressPtr addr); -int virDomainDeviceDriveAddressIsValid(virDomainDeviceDriveAddressPtr addr); -int virDomainDeviceVirtioSerialAddressIsValid(virDomainDeviceVirtioSerialAddressPtr addr); -int virDomainDeviceUSBAddressIsValid(virDomainDeviceUSBAddressPtr addr); void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info); void virDomainDefClearPCIAddresses(virDomainDefPtr def); void virDomainDefClearDeviceAliases(virDomainDefPtr def);