diff mbox series

[1/2] qapi: Do not generate default switch case in gen_visit_object_members()

Message ID 20230224155451.20211-2-philmd@linaro.org
State New
Headers show
Series qapi: Simplify enum generation | expand

Commit Message

Philippe Mathieu-Daudé Feb. 24, 2023, 3:54 p.m. UTC
When iterating over a QAPISchemaEnumType, all possible
values are covered. The 'default' switch case is unreachable,
remove it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 scripts/qapi/visit.py | 2 --
 1 file changed, 2 deletions(-)

Comments

Juan Quintela Feb. 27, 2023, 12:40 p.m. UTC | #1
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
> When iterating over a QAPISchemaEnumType, all possible
> values are covered. The 'default' switch case is unreachable,
> remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Juan Quintela <quintela@redhat.com>

Althought my qapi is rusty.
Markus Armbruster Feb. 27, 2023, 1:14 p.m. UTC | #2
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

> When iterating over a QAPISchemaEnumType, all possible
> values are covered. The 'default' switch case is unreachable,
> remove it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  scripts/qapi/visit.py | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
> index 26a584ee4c..f66a31a963 100644
> --- a/scripts/qapi/visit.py
> +++ b/scripts/qapi/visit.py
> @@ -159,8 +159,6 @@ def gen_visit_object_members(name: str,
>  
>              ret += var.ifcond.gen_endif()
>          ret += mcgen('''
> -    default:
> -        abort();
>      }
>  ''')

This results in a bunch of warnings like

    warning: enumeration value ‘FOO__MAX’ not handled in switch [-Wswitch]

Obvious fix: squash into the next patch.
diff mbox series

Patch

diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py
index 26a584ee4c..f66a31a963 100644
--- a/scripts/qapi/visit.py
+++ b/scripts/qapi/visit.py
@@ -159,8 +159,6 @@  def gen_visit_object_members(name: str,
 
             ret += var.ifcond.gen_endif()
         ret += mcgen('''
-    default:
-        abort();
     }
 ''')