Convert the field and fill in missing cases to switch()
statements.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 26 ++++++++++++++++++--------
src/conf/domain_conf.h | 9 ++++++---
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_domain_address.c | 12 +++++++++++-
src/qemu/qemu_hotplug.c | 4 ++--
src/qemu/qemu_validate.c | 2 +-
src/vbox/vbox_common.c | 2 +-
8 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 35cb14b986..95a71b204f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2473,7 +2473,7 @@ virDomainControllerDefNew(virDomainControllerType type)
def->model = -1;
def->idx = -1;
- switch ((virDomainControllerType) def->type) {
+ switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
def->opts.vioserial.ports = -1;
def->opts.vioserial.vectors = -1;
@@ -8265,7 +8265,7 @@ static int
virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
const char *model)
{
- switch ((virDomainControllerType)def->type) {
+ switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
return virDomainControllerModelSCSITypeFromString(model);
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
@@ -8293,7 +8293,7 @@ static const char *
virDomainControllerModelTypeToString(virDomainControllerDef *def,
int model)
{
- switch ((virDomainControllerType)def->type) {
+ switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
return virDomainControllerModelSCSITypeToString(model);
case VIR_DOMAIN_CONTROLLER_TYPE_USB:
@@ -8324,7 +8324,7 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
unsigned int flags)
{
g_autoptr(virDomainControllerDef) def = NULL;
- virDomainControllerType type = 0;
+ virDomainControllerType type = VIR_DOMAIN_CONTROLLER_TYPE_IDE;
xmlNodePtr driver = NULL;
g_autofree xmlNodePtr *targetNodes = NULL;
int ntargetNodes = 0;
@@ -8539,6 +8539,13 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
break;
}
+ case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
+ case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
+ case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ case VIR_DOMAIN_CONTROLLER_TYPE_SATA:
+ case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
+ case VIR_DOMAIN_CONTROLLER_TYPE_ISA:
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
default:
break;
}
@@ -16031,7 +16038,10 @@ virDomainEmulatorPinDefParseXML(xmlNodePtr node)
virDomainControllerDef *
-virDomainDefAddController(virDomainDef *def, int type, int idx, int model)
+virDomainDefAddController(virDomainDef *def,
+ virDomainControllerType type,
+ int idx,
+ int model)
{
virDomainControllerDef *cont;
@@ -16106,7 +16116,7 @@ virDomainDefAddUSBController(virDomainDef *def, int idx, int
model)
int
virDomainDefMaybeAddController(virDomainDef *def,
- int type,
+ virDomainControllerType type,
int idx,
int model)
{
@@ -21719,7 +21729,7 @@ virDomainDefCheckABIStability(virDomainDef *src,
static int
virDomainDefAddDiskControllersForType(virDomainDef *def,
- int controllerType,
+ virDomainControllerType controllerType,
int diskBus)
{
size_t i;
@@ -22981,7 +22991,7 @@ virDomainControllerDefFormat(virBuffer *buf,
if (model)
virBufferEscapeString(&attrBuf, " model='%s'", model);
- switch ((virDomainControllerType) def->type) {
+ switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
if (def->opts.vioserial.ports != -1) {
virBufferAsprintf(&attrBuf, " ports='%d'",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index fc612f3adb..9dadda2d1d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -784,7 +784,7 @@ struct _virDomainXenbusControllerOpts {
/* Stores the virtual disk controller configuration */
struct _virDomainControllerDef {
- int type;
+ virDomainControllerType type;
int idx;
int model; /* -1 == undef */
unsigned int queues;
@@ -4280,12 +4280,15 @@ VIR_ENUM_DECL(virDomainCpuPlacementMode);
VIR_ENUM_DECL(virDomainStartupPolicy);
virDomainControllerDef *
-virDomainDefAddController(virDomainDef *def, int type, int idx, int model);
+virDomainDefAddController(virDomainDef *def,
+ virDomainControllerType type,
+ int idx,
+ int model);
int
virDomainDefAddUSBController(virDomainDef *def, int idx, int model);
int
virDomainDefMaybeAddController(virDomainDef *def,
- int type,
+ virDomainControllerType type,
int idx,
int model);
int
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 701efd46b4..17d7bfcfd3 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2802,7 +2802,7 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef,
*devprops = NULL;
- switch ((virDomainControllerType)def->type) {
+ switch (def->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
if (!(props = qemuBuildControllerSCSIDevProps(def, qemuCaps)))
return -1;
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 47c3d69bda..16a8267726 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5540,7 +5540,7 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
virQEMUCaps *qemuCaps,
unsigned int parseFlags)
{
- switch ((virDomainControllerType)cont->type) {
+ switch (cont->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
/* Set the default SCSI controller model if not already set */
if (qemuDomainSetSCSIControllerModel(def, cont, qemuCaps) < 0)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 00742d3c0e..2e58930eec 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -608,7 +608,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev,
case VIR_DOMAIN_DEVICE_CONTROLLER: {
virDomainControllerDef *cont = dev->data.controller;
- switch ((virDomainControllerType)cont->type) {
+ switch (cont->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_PCI:
return virDomainPCIControllerModelToConnectType(cont->model);
@@ -1984,6 +1984,16 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDef *def,
}
}
break;
+
+ case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
+ case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
+ case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
+ case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL:
+ case VIR_DOMAIN_CONTROLLER_TYPE_CCID:
+ case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS:
+ case VIR_DOMAIN_CONTROLLER_TYPE_ISA:
+ case VIR_DOMAIN_CONTROLLER_TYPE_LAST:
+ break;
}
}
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index 21154892ae..2fbd46325f 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -5534,7 +5534,7 @@ qemuDomainDiskControllerIsBusy(virDomainObj *vm,
continue;
/* check whether the disk uses this type controller */
- switch ((virDomainControllerType) detach->type) {
+ switch (detach->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
if (disk->bus != VIR_DOMAIN_DISK_BUS_IDE)
continue;
@@ -5599,7 +5599,7 @@ static bool
qemuDomainControllerIsBusy(virDomainObj *vm,
virDomainControllerDef *detach)
{
- switch ((virDomainControllerType) detach->type) {
+ switch (detach->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
case VIR_DOMAIN_CONTROLLER_TYPE_SCSI:
diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 315fc676f2..2fcc86bb22 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -4036,7 +4036,7 @@ qemuValidateDomainDeviceDefController(const virDomainControllerDef
*controller,
if (qemuValidateDomainDeviceDefControllerAttributes(controller) < 0)
return -1;
- switch ((virDomainControllerType)controller->type) {
+ switch (controller->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_IDE:
ret = qemuValidateDomainDeviceDefControllerIDE(controller, def);
break;
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 490f337a56..de3c9989a5 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -467,7 +467,7 @@ vboxSetStorageController(virDomainControllerDef *controller,
int ret = -1;
/* libvirt controller type => vbox bus type */
- switch ((virDomainControllerType) controller->type) {
+ switch (controller->type) {
case VIR_DOMAIN_CONTROLLER_TYPE_FDC:
VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_FLOPPY_NAME, &controllerName);
vboxBusType = StorageBus_Floppy;
--
2.41.0