]> xenbits.xensource.com Git - libvirt.git/commitdiff
src: Drop needless typecast to virDomainDeviceType
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Sep 2023 15:11:12 +0000 (17:11 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Sep 2023 08:34:48 +0000 (10:34 +0200)
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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/ch/ch_domain.c
src/conf/domain_conf.c
src/conf/domain_postparse.c
src/conf/domain_validate.c
src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain_address.c
src/qemu/qemu_driver.c
src/qemu/qemu_hotplug.c
src/qemu/qemu_validate.c

index d6b64b6c59b42e3f62d375e950a3d1e3f6a73f98..866f0d899ad32c32986c98c45a8a3c22caedc638 100644 (file)
@@ -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:
index 9d819c3dab482cc5139b74248cc6e8fa157c2978..306547e798ff1b3b5d51d29a28f250d9d4f197cb 100644 (file)
@@ -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)))
index b76e8dcc5c4a96026a6e852b45e75c9cc8633c4c..e79913b73fd94604e52a81c37df86ee0315794d1 100644 (file)
@@ -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;
index 53d920b2b38be4f23e94074603a193bb64a26009..a8f90af3aa2c93ca8ff7a4f8b7b5d33240610cee 100644 (file)
@@ -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);
 
index f9e4de9bd7d89c8d4bd30569fd217e88871864a0..6de0bdf977355951df99c7ee08cd8541a01b02ee 100644 (file)
@@ -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";
index 52ea8f649dae545140c6164f2eeae19a829e9840..e578df624bf69e1a03d73688d6674b9ec258f6dc 100644 (file)
@@ -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;
index 01f44a4991c9d47ca77c58132ebf9de1e0917780..38411b487224a5fff519d9b3439d5e0ff57d99a7 100644 (file)
@@ -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;
 
index 0d4da937b0229e17e3355519ab9ed6e0c766dd34..28ec40e3513eb442a2db8bf1720ec61a16d48fe3 100644 (file)
@@ -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) {
index 177ca87d11acfbb919777554fa47767193105ef8..0d5f253bb9ce72f9e1c5f14e2e7c9c4bffacd3ac 100644 (file)
@@ -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);
index c7deac625135ddf56bb32873bd601271dcafd549..3b57fa3c21edee8ae3f8a1944cec1a0a5a102ed5 100644 (file)
@@ -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);