[libvirt] [PATCH v2 1/2] Introduce virCheckFlags for consistent flags checking

Eric Blake eblake at redhat.com
Thu Apr 15 14:36:46 UTC 2010

On 04/13/2010 10:25 AM, Jiri Denemark wrote:
> The idea is that every API implementation in driver which has flags
> parameter should first call virCheckFlags() macro to check the function
> was called with supported flags:
>     virCheckFlags(VIR_SUPPORTED_FLAG_1 |
>                   VIR_SUPPORTED_FLAG_2 |
>                   VIR_ANOTHER_SUPPORTED_FLAG, -1);
> The error massage which is printed when unsupported flags are passed
> looks like:
>     invalid argument in virFooBar: unsupported flags (0x2)
> Where the unsupported flags part only prints those flags which were
> passed but are not supported rather than all flags passed.
> ---
>  src/internal.h |   23 +++++++++++++++++++++++

I like this location better than the v1 attempt.  ACK (but note my
comments on Matthias' ESX patch, depending on which gets pushed first).

> +/**
> + * virCheckFlags:
> + * @supported: an OR'ed set of supported flags

Is it worth documenting that this must be 'int' or 'unsigned int', and
that the macro doesn't work on uint64_t?  Or maybe it's worth trying to
figure out a way to refactor the macro to support both sizes?  But that
can be a followup, if we find a case where we ever need a larger size
for flags, so it shouldn't hold up committing this.

Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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

More information about the libvir-list mailing list