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(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org