Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
libvirt-override.c | 9 +++------
typewrappers.c | 54 ++++++++++++++++++------------------------------------
2 files changed, 21 insertions(+), 42 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index d2279de..4d0fb92 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -1960,7 +1960,6 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
for (i = 0; i < ncred; i++) {
PyObject *pycreditem;
pycreditem = PyList_New(5);
- Py_INCREF(Py_None);
PyTuple_SetItem(pycred, i, pycreditem);
PyList_SetItem(pycreditem, 0, libvirt_intWrap((long) cred[i].type));
PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt));
@@ -1968,17 +1967,15 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
PyList_SetItem(pycreditem, 2,
libvirt_constcharPtrWrap(cred[i].challenge));
} else {
- Py_INCREF(Py_None);
- PyList_SetItem(pycreditem, 2, Py_None);
+ PyList_SetItem(pycreditem, 2, VIR_PY_NONE);
}
if (cred[i].defresult) {
PyList_SetItem(pycreditem, 3,
libvirt_constcharPtrWrap(cred[i].defresult));
} else {
- Py_INCREF(Py_None);
- PyList_SetItem(pycreditem, 3, Py_None);
+ PyList_SetItem(pycreditem, 3, VIR_PY_NONE);
}
- PyList_SetItem(pycreditem, 4, Py_None);
+ PyList_SetItem(pycreditem, 4, VIR_PY_NONE);
}
PyTuple_SetItem(list, 0, pycred);
diff --git a/typewrappers.c b/typewrappers.c
index 6507e0f..246f8af 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -97,8 +97,7 @@ libvirt_charPtrSizeWrap(char *str, Py_ssize_t size)
PyObject *ret;
if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyBytes_FromStringAndSize(str, size);
@@ -114,8 +113,7 @@ libvirt_charPtrWrap(char *str)
PyObject *ret;
if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyUnicode_FromString(str);
@@ -131,8 +129,7 @@ libvirt_constcharPtrWrap(const char *str)
PyObject *ret;
if (str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
#if PY_MAJOR_VERSION > 2
ret = PyUnicode_FromString(str);
@@ -420,8 +417,7 @@ libvirt_virDomainPtrWrap(virDomainPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virDomainPtr", NULL);
@@ -434,8 +430,7 @@ libvirt_virNetworkPtrWrap(virNetworkPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virNetworkPtr", NULL);
@@ -448,8 +443,7 @@ libvirt_virInterfacePtrWrap(virInterfacePtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virInterfacePtr", NULL);
@@ -462,8 +456,7 @@ libvirt_virStoragePoolPtrWrap(virStoragePoolPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virStoragePoolPtr", NULL);
@@ -476,8 +469,7 @@ libvirt_virStorageVolPtrWrap(virStorageVolPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virStorageVolPtr", NULL);
@@ -490,8 +482,7 @@ libvirt_virConnectPtrWrap(virConnectPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virConnectPtr", NULL);
@@ -504,8 +495,7 @@ libvirt_virNodeDevicePtrWrap(virNodeDevicePtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virNodeDevicePtr", NULL);
@@ -518,8 +508,7 @@ libvirt_virSecretPtrWrap(virSecretPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virSecretPtr", NULL);
@@ -532,8 +521,7 @@ libvirt_virNWFilterPtrWrap(virNWFilterPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virNWFilterPtr", NULL);
@@ -546,8 +534,7 @@ libvirt_virStreamPtrWrap(virStreamPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virStreamPtr", NULL);
@@ -560,8 +547,7 @@ libvirt_virDomainSnapshotPtrWrap(virDomainSnapshotPtr node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virDomainSnapshotPtr", NULL);
@@ -574,9 +560,8 @@ libvirt_virEventHandleCallbackWrap(virEventHandleCallback node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
printf("%s: WARNING - Wrapping None\n", __func__);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virEventHandleCallback", NULL);
@@ -590,8 +575,7 @@ libvirt_virEventTimeoutCallbackWrap(virEventTimeoutCallback node)
if (node == NULL) {
printf("%s: WARNING - Wrapping None\n", __func__);
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virEventTimeoutCallback", NULL);
@@ -604,8 +588,7 @@ libvirt_virFreeCallbackWrap(virFreeCallback node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "virFreeCallback", NULL);
@@ -618,8 +601,7 @@ libvirt_virVoidPtrWrap(void* node)
PyObject *ret;
if (node == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
+ return VIR_PY_NONE;
}
ret = libvirt_buildPyObject(node, "void*", NULL);
--
2.5.3