The 'type' member of _virDomainDeviceDef is already declared of virDomainDeviceType type. Hence, there is no need to typecast the variable when passing to switch() statements. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/ch/ch_domain.c | 2 +- src/conf/domain_conf.c | 8 ++++---- src/conf/domain_postparse.c | 2 +- src/conf/domain_validate.c | 2 +- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_domain.c | 6 +++--- src/qemu/qemu_domain_address.c | 4 ++-- src/qemu/qemu_driver.c | 6 +++--- src/qemu/qemu_hotplug.c | 10 +++++----- src/qemu/qemu_validate.c | 2 +- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index d6b64b6c59..866f0d899a 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -146,7 +146,7 @@ chValidateDomainDeviceDef(const virDomainDeviceDef *dev, void *opaque G_GNUC_UNUSED, void *parseOpaque G_GNUC_UNUSED) { - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_MEMORY: diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9d819c3dab..306547e798 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3520,7 +3520,7 @@ void virDomainDeviceDefFree(virDomainDeviceDef *def) if (!def) return; - switch ((virDomainDeviceType) def->type) { + switch (def->type) { case VIR_DOMAIN_DEVICE_DISK: virDomainDiskDefFree(def->data.disk); break; @@ -4468,7 +4468,7 @@ virDomainObjGetOneDef(virDomainObj *vm, virDomainDeviceInfo * virDomainDeviceGetInfo(const virDomainDeviceDef *device) { - switch ((virDomainDeviceType) device->type) { + switch (device->type) { case VIR_DOMAIN_DEVICE_DISK: return &device->data.disk->info; case VIR_DOMAIN_DEVICE_FS: @@ -4541,7 +4541,7 @@ void virDomainDeviceSetData(virDomainDeviceDef *device, void *devicedata) { - switch ((virDomainDeviceType) device->type) { + switch (device->type) { case VIR_DOMAIN_DEVICE_DISK: device->data.disk = devicedata; break; @@ -13777,7 +13777,7 @@ virDomainDeviceDefParse(const char *xmlStr, if (virDomainDeviceDefParseType((const char *)node->name, &dev->type) < 0) return NULL; - switch ((virDomainDeviceType) dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: if (!(dev->data.disk = virDomainDiskDefParseXML(xmlopt, node, ctxt, flags))) diff --git a/src/conf/domain_postparse.c b/src/conf/domain_postparse.c index b76e8dcc5c..e79913b73f 100644 --- a/src/conf/domain_postparse.c +++ b/src/conf/domain_postparse.c @@ -684,7 +684,7 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDef *dev, { int ret = -1; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_CHR: ret = virDomainChrDefPostParse(dev->data.chr, def); break; diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 53d920b2b3..a8f90af3aa 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -2847,7 +2847,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, if (virDomainDeviceInfoValidate(dev) < 0) return -1; - switch ((virDomainDeviceType) dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: return virDomainDiskDefValidate(def, dev->data.disk); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f9e4de9bd7..6de0bdf977 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -796,7 +796,7 @@ qemuBuildVirtioDevGetConfigDev(const virDomainDeviceDef *device, bool *has_ntmodel, bool *useBusSuffix) { - switch ((virDomainDeviceType) device->type) { + switch (device->type) { case VIR_DOMAIN_DEVICE_DISK: if (virStorageSourceGetActualType(device->data.disk->src) == VIR_STORAGE_TYPE_VHOST_USER) *baseName = "vhost-user-blk"; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 52ea8f649d..e578df624b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6175,7 +6175,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDef *dev, virQEMUCaps *qemuCaps = parseOpaque; int ret = -1; - switch ((virDomainDeviceType) dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_NET: ret = qemuDomainDeviceNetDefPostParse(dev->data.net, def, qemuCaps); break; @@ -10297,7 +10297,7 @@ qemuDomainPrepareChardevSourceOne(virDomainDeviceDef *dev, struct qemuDomainPrepareChardevSourceData *data = opaque; qemuDomainChrSourcePrivate *charpriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(charsrc); - switch ((virDomainDeviceType) dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_RNG: @@ -12148,7 +12148,7 @@ qemuDomainDeviceBackendChardevForeachOne(virDomainDeviceDef *dev, qemuDomainDeviceBackendChardevForeachCallback cb, void *opaque) { - switch ((virDomainDeviceType) dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: if (virStorageSourceGetActualType(dev->data.disk->src) != VIR_STORAGE_TYPE_VHOST_USER) return 0; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 01f44a4991..38411b4872 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -522,7 +522,7 @@ qemuDomainAssignVirtioMMIOAddresses(virDomainDef *def, static bool qemuDomainDeviceSupportZPCI(virDomainDeviceDef *device) { - switch ((virDomainDeviceType)device->type) { + switch (device->type) { case VIR_DOMAIN_DEVICE_CHR: return false; @@ -604,7 +604,7 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDeviceDef *dev, virDomainPCIConnectFlags pciFlags = (VIR_PCI_CONNECT_TYPE_PCI_DEVICE | VIR_PCI_CONNECT_AUTOASSIGN); - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_CONTROLLER: { virDomainControllerDef *cont = dev->data.controller; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0d4da937b0..28ec40e351 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6624,7 +6624,7 @@ qemuDomainAttachDeviceConfig(virDomainDef *vmdef, virDomainRedirdevDef *redirdev; virDomainShmemDef *shmem; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: disk = dev->data.disk; if (virDomainDiskIndexByName(vmdef, disk->dst, true) >= 0) { @@ -6843,7 +6843,7 @@ qemuDomainDetachDeviceConfig(virDomainDef *vmdef, virDomainMemoryDef *mem; int idx; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: disk = dev->data.disk; if (!(det_disk = virDomainDiskRemoveByName(vmdef, disk->dst))) { @@ -7041,7 +7041,7 @@ qemuDomainUpdateDeviceConfig(virDomainDef *vmdef, virDomainDeviceDef oldDev = { .type = dev->type }; int pos; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: newDisk = dev->data.disk; if ((pos = virDomainDiskIndexByName(vmdef, newDisk->dst, false)) < 0) { diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 177ca87d11..0d5f253bb9 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3307,7 +3307,7 @@ qemuDomainAttachDeviceLive(virDomainObj *vm, &chardevBackendData) < 0) return -1; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL); ret = qemuDomainAttachDeviceDiskLive(driver, vm, dev); @@ -5150,7 +5150,7 @@ qemuDomainRemoveAuditDevice(virDomainObj *vm, virDomainDeviceDef *detach, bool success) { - switch ((virDomainDeviceType)detach->type) { + switch (detach->type) { case VIR_DOMAIN_DEVICE_DISK: virDomainAuditDisk(vm, detach->data.disk->src, NULL, "detach", success); break; @@ -5231,7 +5231,7 @@ qemuDomainRemoveDevice(virQEMUDriver *driver, alias = g_strdup(info->alias); info = NULL; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_CHR: /* We must return directly after calling * qemuDomainRemoveChrDevice because it is called directly @@ -6058,7 +6058,7 @@ qemuDomainDetachDeviceLive(virDomainObj *vm, int ret = -1; int rc; - switch ((virDomainDeviceType)match->type) { + switch (match->type) { /* * lease and chr devices don't follow the standard pattern of * the others, so they must have their own self-contained @@ -7100,7 +7100,7 @@ qemuDomainUpdateDeviceLive(virDomainObj *vm, virDomainDeviceDef oldDev = { .type = dev->type }; int idx; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_DISK: qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL); return qemuDomainChangeDiskLive(vm, dev, driver, force); diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index c7deac6251..3b57fa3c21 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -5068,7 +5068,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev, if (qemuValidateDomainDeviceInfo(dev, def, qemuCaps) < 0) return -1; - switch ((virDomainDeviceType)dev->type) { + switch (dev->type) { case VIR_DOMAIN_DEVICE_NET: return qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps); -- 2.41.0