Re: [PATCH v2 14/42] m4: enforce that all enum cases are listed in switch statements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 02/15/2018 11:43 AM, Daniel P. Berrangé wrote:
> 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.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
> ---
>  m4/virt-compile-warnings.m4 | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 

Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>

John

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux