On 7/20/22 15:44, Peter Krempa wrote:
> On Wed, Jul 20, 2022 at 15:11:08 +0200, Kristina Hanicova wrote:
>> Switch is used for just one case, so I replaced it with a simple
>> if condition.
>>
>> Signed-off-by: Kristina Hanicova <khani...@redhat.com>
>> ---
>>  src/conf/domain_conf.c | 7 +------
>>  1 file changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index b903dac1cb..f51476c968 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -2904,8 +2904,7 @@ void virDomainChrDefFree(virDomainChrDef *def)
>>      if (!def)
>>          return;
>>  
>> -    switch (def->deviceType) {
> 
> Alternatively a more future proof (but more verbose) approach which we
> are doing in many places is to use the proper type (either by fixing the
> struct to use proper type, or typecasting) in the switch expression and 
> then simply enumerate all values.
> 
> That way any further addition doesn't have to un-do this patch.

When I tried to do that it wasn't met with much appreciation:

https://listman.redhat.com/archives/libvir-list/2022-May/231776.html

Michal

Reply via email to