[PATCH 01/17] Drop needless typecast to virStorageType enum

Michal Privoznik posted 17 patches 3 years, 8 months ago
[PATCH 01/17] Drop needless typecast to virStorageType enum
Posted by Michal Privoznik 3 years, 8 months ago
There are three places (two in domain_conf.c and one in
qemu_migration.c) where a virStorageSource->type is typecasted to
virStorageType (for the purpose of catching missing enum member
in a switch() statement at compile time). This is needless,
because as of v8.2.0-rc1~120 the struct member is of proper type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/conf/domain_conf.c    | 4 ++--
 src/qemu/qemu_migration.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 0b30ebc96b..6ff994dd12 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8659,7 +8659,7 @@ virDomainStorageSourceParse(xmlNodePtr node,
 
     ctxt->node = node;
 
-    switch ((virStorageType)src->type) {
+    switch (src->type) {
     case VIR_STORAGE_TYPE_FILE:
         src->path = virXMLPropString(node, "file");
         break;
@@ -23350,7 +23350,7 @@ virDomainDiskSourceFormat(virBuffer *buf,
     g_auto(virBuffer) attrBuf = VIR_BUFFER_INITIALIZER;
     g_auto(virBuffer) childBuf = VIR_BUFFER_INIT_CHILD(buf);
 
-    switch ((virStorageType)src->type) {
+    switch (src->type) {
     case VIR_STORAGE_TYPE_FILE:
         virBufferEscapeString(&attrBuf, " file='%s'", src->path);
         break;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 38596fa4de..176c25cd11 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -182,7 +182,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn,
 
     VIR_DEBUG("Precreate disk type=%s", virStorageTypeToString(disk->src->type));
 
-    switch ((virStorageType)disk->src->type) {
+    switch (disk->src->type) {
     case VIR_STORAGE_TYPE_FILE:
         if (!virDomainDiskGetSource(disk)) {
             VIR_DEBUG("Dropping sourceless disk '%s'",
-- 
2.35.1
Re: [PATCH 01/17] Drop needless typecast to virStorageType enum
Posted by Boris Fiuczynski 3 years, 8 months ago
On 5/23/22 3:08 PM, Michal Privoznik wrote:
> There are three places (two in domain_conf.c and one in
> qemu_migration.c) where a virStorageSource->type is typecasted to
> virStorageType (for the purpose of catching missing enum member
> in a switch() statement at compile time). This is needless,
> because as of v8.2.0-rc1~120 the struct member is of proper type.
> 
> Signed-off-by: Michal Privoznik<mprivozn@redhat.com>
> ---

Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>

-- 
Mit freundlichen Grüßen/Kind regards
    Boris Fiuczynski

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294