[libvirt] [PATCH] Don't use enums in TPM struct fields

Peter Krempa pkrempa at redhat.com
Thu Jun 7 08:25:11 UTC 2018


On Thu, Jun 07, 2018 at 09:15:06 +0100, Daniel Berrange wrote:
> On Wed, Jun 06, 2018 at 08:32:39PM +0200, Ján Tomko wrote:
> > This deprives us of the -Wswitch-enum warning on all compilers
> > because some don't detect the bogus negative value comparison.
> > And the comment has even less power than the clang warning. So:
> > 
> > 1. Is it actually worth the trouble to store enum values in
> >   typedef'd enums?
> > 2. If so, can we make TypeFromString usage less cumbersome?
> 
> We could add a explicit
> 
>    VIR_XXXXX_INVALID = -1,
> 
> entry to every single enum, which will force the compiler to
> always use a signed int for representing the enum.

That would force us to add that to all switch statements with the
correct type, which seems a waste.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180607/bb520915/attachment-0001.sig>


More information about the libvir-list mailing list