On 03/19/2012 12:03 PM, Eric Blake wrote:
Why are you doing this for just VIR_TYPED_PARAM_ULLONG? I argue that we
should be doing it for all of the integral conversions.
In fact, I'd argue that we want new helper functions in typewrappers.c,
as counterparts to our libvirt_intWrap() and friends. Perhaps:
/* Return 0 if obj could be unwrapped into the corresponding C type, -1
with python exception set otherwise. */
int libvirt_intUnwrap(PyObject *obj, int *val);
int libvirt_uintUnwrap(PyObject *obj, unsigned int *val);
int libvirt_longlongUnwrap(PyObject *obj, long long *val);
int libvirt_ulonglongUnwrap(PyObject *obj, unsigned long long *val);
Then the code in question simplifies to:
case VIR_TYPED_PARAM_ULLONG:
{
unsigned long long ullong_val;
if (libvirt_ulonglongUnwrap(value, &ullong_val) < 0)
goto cleanup;
temp->value.ul = ullong_val;
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org