]> git.ipfire.org Git - thirdparty/libvirt.git/commit
m4: enforce that all enum cases are listed in switch statements
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 14 Feb 2018 09:49:42 +0000 (09:49 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 21 Feb 2018 16:59:48 +0000 (16:59 +0000)
commit67966ad518199f51c4b9d654ad9db5f7bab1ff83
treebf56775f5373f1249745d38ba8ca936fe143f95c
parente694adf8ca1b9d1e50014c50ae31642103af2cd6
m4: enforce that all enum cases are listed in switch statements

As a general rule any time we switch() on something that is an enum, we
want to have a case for every enum constant. The -Wswitch warning will
report any switch where we've violated this rule, except if that switch
has a default case.

Unfortunately it is reasonable to want to list all enum constants *and*
also have a default case. To get a warning in that scenario requires
that we turn on -Wswitch-enum.

In a few cases where we explicitly don't want to list all enum cases, we
can discard the enum type checking by casting the value to a plain int.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
m4/virt-compile-warnings.m4