Pattern of using switch instead of a long if else construction is used everywhere, so I used it here as well to make the code more consistent (and remove that else after return). I also included all the values from the enum. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- src/conf/domain_conf.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 41d23cfe2a..a4b3a49086 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8055,19 +8055,26 @@ static int virDomainControllerModelTypeFromString(const virDomainControllerDef *def, const char *model) { - if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) + switch ((virDomainControllerType)def->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: return virDomainControllerModelSCSITypeFromString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) + case VIR_DOMAIN_CONTROLLER_TYPE_USB: return virDomainControllerModelUSBTypeFromString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: return virDomainControllerModelPCITypeFromString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: return virDomainControllerModelIDETypeFromString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) + case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: return virDomainControllerModelVirtioSerialTypeFromString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA) + case VIR_DOMAIN_CONTROLLER_TYPE_ISA: return virDomainControllerModelISATypeFromString(model); - + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + case VIR_DOMAIN_CONTROLLER_TYPE_CCID: + case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: + case VIR_DOMAIN_CONTROLLER_TYPE_LAST: + return -1; + } return -1; } @@ -8076,19 +8083,26 @@ static const char * virDomainControllerModelTypeToString(virDomainControllerDef *def, int model) { - if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) + switch ((virDomainControllerType)def->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: return virDomainControllerModelSCSITypeToString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) + case VIR_DOMAIN_CONTROLLER_TYPE_USB: return virDomainControllerModelUSBTypeToString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: return virDomainControllerModelPCITypeToString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_IDE) + case VIR_DOMAIN_CONTROLLER_TYPE_IDE: return virDomainControllerModelIDETypeToString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL) + case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: return virDomainControllerModelVirtioSerialTypeToString(model); - else if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_ISA) + case VIR_DOMAIN_CONTROLLER_TYPE_ISA: return virDomainControllerModelISATypeToString(model); - + case VIR_DOMAIN_CONTROLLER_TYPE_FDC: + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + case VIR_DOMAIN_CONTROLLER_TYPE_CCID: + case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: + case VIR_DOMAIN_CONTROLLER_TYPE_LAST: + return NULL; + } return NULL; } -- 2.35.3