Re: [libvirt] PATCH: Helper for enumerations

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

 



"Daniel P. Berrange" <berrange@xxxxxxxxxx> wrote:
> There are quite a few places in our code where we have to convert from
> a string to an int enumeration, and vica-verca. This is tedious code to
> write, and I'm about to introduce a tonne more enumerations in the new
> generic domain XML parser / generator. So I reckon its time for some
> helper APIs
...

Very nice.  That's been annoying me for some time.
ACK

> diff -r bc1615919490 src/util.c
> --- a/src/util.c	Fri Jun 13 15:43:20 2008 +0100
> +++ b/src/util.c	Fri Jun 13 18:52:39 2008 +0100
> @@ -798,3 +798,24 @@
>      return idx;
>  }
>
> +int virEnumFromString(const char *const*types,
> +                      int ntypes,

If using an unsigned type (size_t or unsigned int) doesn't cause too
much disruption among the callers, that'd be nice, since negative
"ntypes" is not useful.

> +                      const char *type)
> +{
> +    int i;

matching type here, too.

ACK, either way.

--
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]