[PATCH v2 5/8] domain_conf: extend switch with if in virDomainChrDefFree()

Kristina Hanicova posted 8 patches 3 years, 6 months ago
[PATCH v2 5/8] domain_conf: extend switch with if in virDomainChrDefFree()
Posted by Kristina Hanicova 3 years, 6 months ago
Switch is used for just one case, but a more future proof
approach is to handle all enum values.

Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
---
 src/conf/domain_conf.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index b903dac1cb..41eb105a6c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -2904,7 +2904,7 @@ void virDomainChrDefFree(virDomainChrDef *def)
     if (!def)
         return;
 
-    switch (def->deviceType) {
+    switch ((virDomainChrDeviceType)def->deviceType) {
     case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
         switch (def->targetType) {
         case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
@@ -2918,7 +2918,10 @@ void virDomainChrDefFree(virDomainChrDef *def)
         }
         break;
 
-    default:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
+    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
         break;
     }
 
-- 
2.35.3
Re: [PATCH v2 5/8] domain_conf: extend switch with if in virDomainChrDefFree()
Posted by Kristina Hanicova 3 years, 6 months ago
sorry for the confusing commit message, it should have been "domain_conf:
extend switch in virDomainChrDefFree()" only:D

Kristina

On Thu, Jul 21, 2022 at 12:46 PM Kristina Hanicova <khanicov@redhat.com>
wrote:

> Switch is used for just one case, but a more future proof
> approach is to handle all enum values.
>
> Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
> ---
>  src/conf/domain_conf.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index b903dac1cb..41eb105a6c 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -2904,7 +2904,7 @@ void virDomainChrDefFree(virDomainChrDef *def)
>      if (!def)
>          return;
>
> -    switch (def->deviceType) {
> +    switch ((virDomainChrDeviceType)def->deviceType) {
>      case VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL:
>          switch (def->targetType) {
>          case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
> @@ -2918,7 +2918,10 @@ void virDomainChrDefFree(virDomainChrDef *def)
>          }
>          break;
>
> -    default:
> +    case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL:
> +    case VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL:
> +    case VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE:
> +    case VIR_DOMAIN_CHR_DEVICE_TYPE_LAST:
>          break;
>      }
>
> --
> 2.35.3
>
>
Re: [PATCH v2 5/8] domain_conf: extend switch with if in virDomainChrDefFree()
Posted by Martin Kletzander 3 years, 6 months ago
On Thu, Jul 21, 2022 at 05:04:43PM +0200, Kristina Hanicova wrote:
>sorry for the confusing commit message, it should have been "domain_conf:
>extend switch in virDomainChrDefFree()" only:D
>

ok, with that and ...

>Kristina
>
>On Thu, Jul 21, 2022 at 12:46 PM Kristina Hanicova <khanicov@redhat.com>
>wrote:
>
>> Switch is used for just one case, but a more future proof
>> approach is to handle all enum values.
>>

... without this

Reviewed-by: Martin Kletzander <mkletzan@redhat.com>