[libvirt] [PATCH 3/3] virSecurityLabelDef: use enum type for @type

Eric Blake eblake at redhat.com
Fri Jul 11 16:59:22 UTC 2014


On 07/11/2014 03:32 AM, Michal Privoznik wrote:
> There's this trend in libvirt of using enum types wherever possible.
> Now that I'm at virSecurityLabelDef let's rework @type item of the
> structure so we don't have to typecast it elsewhere.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/conf/domain_conf.c      | 6 ++++--
>  src/security/security_dac.c | 2 +-
>  src/util/virseclabel.h      | 2 +-
>  3 files changed, 6 insertions(+), 4 deletions(-)

I'm not quite as sure about this one.  This solves the issue of how to
detect errors when parsing strings to enum, but required the use of an
intermediate variable which in turn made the patch a net gain in lines
of code.  If someone forgets to use the intermediate variable for
parsing, this backfires.  On the other hand, parsing string to enum
should be done in just one location, and that's the location touched by
this patch.  I'm 50-50 on whether to take this, so I'd like someone else
to chime in with an opinion.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140711/aa4da96c/attachment-0001.sig>


More information about the libvir-list mailing list