[libvirt] [PATCH] Add overrides for network port UUID getter/lookup methods
Daniel P. Berrangé
berrange at redhat.com
Fri Jan 3 11:34:09 UTC 2020
On Thu, Jan 02, 2020 at 07:46:40PM +0100, Fabiano Fidêncio wrote:
> [snip]
>
> > +static PyObject *
> > +libvirt_virNetworkPortLookupByUUID(PyObject *self ATTRIBUTE_UNUSED,
> > + PyObject *args)
> > +{
> > + virNetworkPortPtr c_retval;
> > + virNetworkPtr net;
> > + PyObject *pyobj_net;
> > + unsigned char *uuid;
> > + int len;
> > +
> > + if (!PyArg_ParseTuple(args, (char *)"Oz#:virNetworkPortLookupByUUID",
> > + &pyobj_net, &uuid, &len))
> > + return NULL;
> > + net = (virNetworkPtr) PyvirNetwork_Get(pyobj_net);
> > +
>
> Shouldn't we also check whether net is NULL here?
We don't because this C code is only called from our Python generated
stub which will always pass a non-NULL pointer. In any case.....
>
> > + if ((uuid == NULL) || (len != VIR_UUID_BUFLEN))
> > + return VIR_PY_NONE;
> > +
> > + LIBVIRT_BEGIN_ALLOW_THREADS;
> > + c_retval = virNetworkPortLookupByUUID(net, uuid);
...this method will report an error if "net" is NULL.
> > + LIBVIRT_END_ALLOW_THREADS;
> > +
> > + return libvirt_virNetworkPortPtrWrap((virNetworkPortPtr) c_retval);
> > +}
> > +
>
> [snip]
>
> With that fixed, Reviewed-by: Fabiano Fidêncio <fidencio at redhat.com>
>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
More information about the libvir-list
mailing list