[PATCH 1/2] python: use simpler methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* python/libvirt-override.c (libvirt_virDomainGetVcpus)
(libvirt_virDomainGetVcpuPinInfo): Use Py_XDECREF instead of
open-coding it.
---
 python/libvirt-override.c |   14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 130e702..da5cb9a 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -1415,15 +1415,9 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
  cleanup:
     VIR_FREE(cpuinfo);
     VIR_FREE(cpumap);
-    /* NB, Py_DECREF is a badly defined macro, so we require
-     * braces here to avoid 'ambiguous else' warnings from
-     * the compiler.
-     * NB. this comment is true at of time of writing wrt to
-     * at least python2.5.
-     */
-    if (pyretval) { Py_DECREF(pyretval); }
-    if (pycpuinfo) { Py_DECREF(pycpuinfo); }
-    if (pycpumap) { Py_DECREF(pycpumap); }
+    Py_XDECREF(pyretval);
+    Py_XDECREF(pycpuinfo);
+    Py_XDECREF(pycpumap);
     return VIR_PY_NONE;
 }

@@ -1584,7 +1578,7 @@ libvirt_virDomainGetVcpuPinInfo(PyObject *self ATTRIBUTE_UNUSED,
 cleanup:
     VIR_FREE(cpumaps);

-    if (pycpumaps) { Py_DECREF(pycpumaps);}
+    Py_XDECREF(pycpumaps);

     return VIR_PY_NONE;
 }
-- 
1.7.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]