[libvirt] [PATCHv3 03/12] python: add API exports for virConnectListAllDomains()
Eric Blake
eblake at redhat.com
Mon Jun 11 21:02:29 UTC 2012
On 06/11/2012 04:33 AM, Peter Krempa wrote:
> This patch adds export of the new API function
> virConnectListAllDomains() to the libvirt-python bindings. The
> virConnect object now has method "listAllDomains" that takes only the
> flags parameter and returns a python list of virDomain object
> corresponding to virDomainPtrs returned by the underlying api.
>
> The implementation is done manually as the generator does not support
> wrapping list of virDomainPtrs into virDomain objects.
> ---
> Diff to v2:
> - Added check for NULL return from libvirt_virDomainPtrWrap()
> static PyObject *
> libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
> - PyObject *args) {
> + PyObject *args) {
As long as we're touching this line, move the { that starts a function
body to its own line.
> +
> + for (i = 0; i < c_retval; i++) {
> + if (!((tmp = libvirt_virDomainPtrWrap(doms[i])) &&
> + !(PyList_SetItem(py_retval, i, tmp) < 0))) {
Accurate, but too many '!' and () to be read easily. I'd write this as:
if ((tmp = libvirt_virDomainPtrWrap(doms[i])) == NULL ||
PyList_SetItem(py_retval, i, tmp) < 0) {
or maybe
if (!(tmp = libvirt_virDomainPtrWrap(doms[i])) ||
PyList_SetItem(py_retval, i, tmp) < 0) {
ACK.
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120611/5f6c2e5b/attachment-0001.sig>
More information about the libvir-list
mailing list