On 09/24/2015 10:01 AM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
libvirt-lxc-override.c | 13 +-
libvirt-override.c | 615 ++++++++++++++++++++++++++++---------------------
2 files changed, 350 insertions(+), 278 deletions(-)
Perhaps could have split these - just for sanity sake of reviewing,
although it's obvious what the supermajority are...
diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c
index b0550c7..316a500 100644
--- a/libvirt-lxc-override.c
+++ b/libvirt-lxc-override.c
@@ -82,17 +82,8 @@ libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(0)) == NULL)
goto error;
- for (i = 0; i < c_retval; i++) {
- PyObject *item = NULL;
-
- if ((item = libvirt_intWrap(fdlist[i])) == NULL)
- goto error;
-
- if (PyList_Append(py_retval, item) < 0) {
- Py_DECREF(item);
- goto error;
- }
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_APPEND_GOTO(py_retval, libvirt_intWrap(fdlist[1]), error);
cleanup:
VIR_FREE(fdlist);
diff --git a/libvirt-override.c b/libvirt-override.c
index c2e9fb9..1f795d9 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -250,15 +250,10 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED,
for (i = 0; i < queried_ncpus; i++) {
cpuparams = ¶ms[i * nparams];
- if ((cpu = getPyVirTypedParameter(cpuparams, i_retval)) == NULL) {
- goto error;
- }
-
- if (PyList_Append(ret, cpu) < 0) {
- Py_DECREF(cpu);
- goto error;
- }
- Py_DECREF(cpu);
+ VIR_PY_LIST_APPEND_GOTO(ret,
+ getPyVirTypedParameter(cpuparams,
+ i_retval),
+ error);
build issue 'cpu' no longer necessary
}
start_cpu += queried_ncpus;
@@ -296,14 +291,8 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED,
i_retval = 0;
}
- if ((total = getPyVirTypedParameter(params, i_retval)) == NULL) {
- goto error;
- }
- if (PyList_Append(ret, total) < 0) {
- Py_DECREF(total);
- goto error;
- }
- Py_DECREF(total);
+ VIR_PY_LIST_APPEND_GOTO(ret, getPyVirTypedParameter(params, i_retval),
+ error);
build issue - 'total' no longer necessary
}
virTypedParamsFree(params, sumparams);
@@ -1267,8 +1256,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
if (info == NULL)
goto cleanup;
- if (PyList_SetItem(pycpuinfo, i, info) < 0)
- goto cleanup;
+ VIR_PY_LIST_SET_GOTO(pycpuinfo, i, info, cleanup);
VIR_PY_TUPLE_SET_GOTO(info, 0, libvirt_intWrap((long)cpuinfo[i].number),
cleanup);
@@ -1286,8 +1274,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
if (info == NULL)
goto cleanup;
- if (PyList_SetItem(pycpumap, i, info) < 0)
- goto cleanup;
+ VIR_PY_LIST_SET_GOTO(pycpumap, i, info, cleanup);
for (j = 0; j < cpunum; j++) {
VIR_PY_TUPLE_SET_GOTO(info, j,
@@ -1488,7 +1475,7 @@ libvirt_virDomainGetVcpuPinInfo(PyObject *self ATTRIBUTE_UNUSED,
if (mapinfo == NULL)
goto cleanup;
- PyList_SetItem(pycpumaps, vcpu, mapinfo);
+ VIR_PY_LIST_SET_GOTO(pycpumaps, vcpu, mapinfo, cleanup);
for (pcpu = 0; pcpu < cpunum; pcpu++) {
VIR_PY_TUPLE_SET_GOTO(mapinfo,
@@ -1688,11 +1675,10 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
}
- if ((iothrtpl = PyTuple_New(2)) == NULL ||
- PyList_SetItem(py_iothrinfo, i, iothrtpl) < 0) {
- Py_XDECREF(iothrtpl);
+ if ((iothrtpl = PyTuple_New(2)) == NULL)
goto cleanup;
- }
+
+ VIR_PY_LIST_SET_GOTO(py_iothrinfo, i, iothrtpl, cleanup);
/* 0: IOThread ID */
VIR_PY_TUPLE_SET_GOTO(iothrtpl, 0, libvirt_uintWrap(iothr->iothread_id),
@@ -1704,17 +1690,11 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self
ATTRIBUTE_UNUSED,
VIR_PY_TUPLE_SET_GOTO(iothrtpl, 1, iothrmap, cleanup);
- for (pcpu = 0; pcpu < cpunum; pcpu++) {
- PyObject *pyused;
- if ((pyused = PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
- pcpu))) == NULL) {
- goto cleanup;
- }
- if (PyList_SetItem(iothrmap, pcpu, pyused) < 0) {
- Py_XDECREF(pyused);
- goto cleanup;
- }
- }
+ for (pcpu = 0; pcpu < cpunum; pcpu++)
+ VIR_PY_LIST_SET_GOTO(iothrmap, pcpu,
+ PyBool_FromLong(VIR_CPU_USED(iothr->cpumap,
+ pcpu)),
+ cleanup);
}
py_retval = py_iothrinfo;
@@ -1994,21 +1974,26 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
VIR_PY_TUPLE_SET_GOTO(pycred, i, pycreditem, cleanup);
- PyList_SetItem(pycreditem, 0, libvirt_intWrap((long) cred[i].type));
- PyList_SetItem(pycreditem, 1, libvirt_constcharPtrWrap(cred[i].prompt));
+ VIR_PY_LIST_SET_GOTO(pycreditem, 0,
+ libvirt_intWrap((long)cred[i].type), cleanup);
+ VIR_PY_LIST_SET_GOTO(pycreditem, 1,
+ libvirt_constcharPtrWrap(cred[i].prompt), cleanup);
+
if (cred[i].challenge) {
- PyList_SetItem(pycreditem, 2,
- libvirt_constcharPtrWrap(cred[i].challenge));
+ VIR_PY_LIST_SET_GOTO(pycreditem, 2,
+ libvirt_constcharPtrWrap(cred[i].challenge),
+ cleanup);
} else {
- PyList_SetItem(pycreditem, 2, VIR_PY_NONE);
+ VIR_PY_LIST_SET_GOTO(pycreditem, 2, VIR_PY_NONE, cleanup);
}
if (cred[i].defresult) {
- PyList_SetItem(pycreditem, 3,
- libvirt_constcharPtrWrap(cred[i].defresult));
+ VIR_PY_LIST_SET_GOTO(pycreditem, 3,
+ libvirt_constcharPtrWrap(cred[i].defresult),
+ cleanup);
} else {
- PyList_SetItem(pycreditem, 3, VIR_PY_NONE);
+ VIR_PY_LIST_SET_GOTO(pycreditem, 3, VIR_PY_NONE, cleanup);
}
- PyList_SetItem(pycreditem, 4, VIR_PY_NONE);
+ VIR_PY_LIST_SET_GOTO(pycreditem, 4, VIR_PY_NONE, cleanup);
}
Py_XINCREF(pycbdata);
@@ -2188,13 +2173,8 @@ libvirt_virConnectGetCPUModelNames(PyObject *self
ATTRIBUTE_UNUSED,
if ((rv = PyList_New(c_retval)) == NULL)
goto error;
- for (i = 0; i < c_retval; i++) {
- PyObject *str;
- if ((str = libvirt_constcharPtrWrap(models[i])) == NULL)
- goto error;
-
- PyList_SET_ITEM(rv, i, str);
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(rv, i, libvirt_constcharPtrWrap(models[i]), error);
done:
if (models) {
@@ -2273,13 +2253,17 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
py_retval = PyList_New(c_retval);
if (ids) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_intWrap(ids[i]));
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i, libvirt_intWrap(ids[i]), error);
VIR_FREE(ids);
}
return py_retval;
+
+ error:
+ VIR_FREE(ids);
+ Py_XDECREF(py_retval);
+ return NULL;
}
#if LIBVIR_CHECK_VERSION(0, 9, 13)
@@ -2311,12 +2295,7 @@ libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virDomainPtrWrap(doms[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
build issue - 'tmp' no longer necessary
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
libvirt_virDomainPtrWrap(doms[i]), error);
/* python steals the pointer */
doms[i] = NULL;
}
@@ -2327,6 +2306,10 @@ libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
virDomainFree(doms[i]);
VIR_FREE(doms);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
@@ -2369,9 +2352,9 @@ libvirt_virConnectListDefinedDomains(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
if (names) {
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
}
cleanup:
@@ -2380,6 +2363,10 @@ libvirt_virConnectListDefinedDomains(PyObject *self
ATTRIBUTE_UNUSED,
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
static PyObject *
@@ -2421,20 +2408,18 @@ libvirt_virDomainSnapshotListNames(PyObject *self
ATTRIBUTE_UNUSED,
if (!py_retval)
goto cleanup;
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i, libvirt_constcharPtrWrap(names[i]), error);
Build issue - 'pyobj_snap' no longer necessary
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 9, 13)
@@ -2466,13 +2451,8 @@ libvirt_virDomainListAllSnapshots(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
- snaps[i] = NULL;
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virDomainSnapshotPtrWrap(snaps[i]), error);
Build issue - 'pyobj_snap' no longer necessary
}
cleanup:
@@ -2481,6 +2461,10 @@ libvirt_virDomainListAllSnapshots(PyObject *self
ATTRIBUTE_UNUSED,
virDomainSnapshotFree(snaps[i]);
VIR_FREE(snaps);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
@@ -2523,21 +2507,18 @@ libvirt_virDomainSnapshotListChildrenNames(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_constcharPtrWrap(names[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
- VIR_FREE(names[i]);
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i, libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 9, 13)
@@ -2568,15 +2549,9 @@ libvirt_virDomainSnapshotListAllChildren(PyObject *self
ATTRIBUTE_UNUSED,
if (!(py_retval = PyList_New(c_retval)))
goto cleanup;
- for (i = 0; i < c_retval; i++) {
- if ((pyobj_snap = libvirt_virDomainSnapshotPtrWrap(snaps[i])) == NULL ||
- PyList_SetItem(py_retval, i, pyobj_snap) < 0) {
- Py_XDECREF(pyobj_snap);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
- snaps[i] = NULL;
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virDomainSnapshotPtrWrap(snaps[i]), error);
Build issue - 'pyobj_snap' no longer necessary
cleanup:
for (i = 0; i < c_retval; i++)
@@ -2584,6 +2559,10 @@ libvirt_virDomainSnapshotListAllChildren(PyObject *self
ATTRIBUTE_UNUSED,
virDomainSnapshotFree(snaps[i]);
VIR_FREE(snaps);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 9, 13) */
@@ -2634,13 +2613,19 @@ libvirt_virDomainGetInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(5)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
- PyList_SetItem(py_retval, 1, libvirt_ulongWrap(info.maxMem));
- PyList_SetItem(py_retval, 2, libvirt_ulongWrap(info.memory));
- PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.nrVirtCpu));
- PyList_SetItem(py_retval, 4,
- libvirt_ulonglongWrap(info.cpuTime));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0, libvirt_intWrap((int) info.state), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1, libvirt_ulongWrap(info.maxMem), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2, libvirt_ulongWrap(info.memory), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 3,
+ libvirt_intWrap((int) info.nrVirtCpu), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 4,
+ libvirt_ulonglongWrap(info.cpuTime), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2670,9 +2655,14 @@ libvirt_virDomainGetState(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(2)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap(state));
- PyList_SetItem(py_retval, 1, libvirt_intWrap(reason));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0, libvirt_intWrap(state), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1, libvirt_intWrap(reason), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2700,10 +2690,16 @@ libvirt_virDomainGetControlInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(3)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap(info.state));
- PyList_SetItem(py_retval, 1, libvirt_intWrap(info.details));
- PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.stateTime));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0, libvirt_intWrap(info.state), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1, libvirt_intWrap(info.details), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.stateTime), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2732,10 +2728,18 @@ libvirt_virDomainGetBlockInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(3)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_ulonglongWrap(info.capacity));
- PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.allocation));
- PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.physical));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_ulonglongWrap(info.capacity), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_ulonglongWrap(info.allocation), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.physical), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2761,15 +2765,22 @@ libvirt_virNodeGetInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(8)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&info.model[0]));
- PyList_SetItem(py_retval, 1, libvirt_longWrap((long) info.memory >> 10));
- PyList_SetItem(py_retval, 2, libvirt_intWrap((int) info.cpus));
- PyList_SetItem(py_retval, 3, libvirt_intWrap((int) info.mhz));
- PyList_SetItem(py_retval, 4, libvirt_intWrap((int) info.nodes));
- PyList_SetItem(py_retval, 5, libvirt_intWrap((int) info.sockets));
- PyList_SetItem(py_retval, 6, libvirt_intWrap((int) info.cores));
- PyList_SetItem(py_retval, 7, libvirt_intWrap((int) info.threads));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_constcharPtrWrap(&info.model[0]), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_longWrap((long) info.memory >> 10), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2, libvirt_intWrap((int) info.cpus), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 3, libvirt_intWrap((int) info.mhz), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 4, libvirt_intWrap((int) info.nodes), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 5, libvirt_intWrap((int) info.sockets), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 6, libvirt_intWrap((int) info.cores), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 7, libvirt_intWrap((int) info.threads), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2796,9 +2807,16 @@ libvirt_virNodeGetSecurityModel(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(2)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&model.model[0]));
- PyList_SetItem(py_retval, 1, libvirt_constcharPtrWrap(&model.doi[0]));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_constcharPtrWrap(&model.model[0]), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_constcharPtrWrap(&model.doi[0]), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -2825,9 +2843,16 @@ libvirt_virDomainGetSecurityLabel(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(2)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_constcharPtrWrap(&label.label[0]));
- PyList_SetItem(py_retval, 1, libvirt_boolWrap(label.enforcing));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_constcharPtrWrap(&label.label[0]), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_boolWrap(label.enforcing), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
#if LIBVIR_CHECK_VERSION(0, 10, 0)
@@ -2860,25 +2885,17 @@ libvirt_virDomainGetSecurityLabelList(PyObject *self
ATTRIBUTE_UNUSED,
for (i = 0 ; i < c_retval ; i++) {
PyObject *entry;
- PyObject *value;
- if (!(entry = PyList_New(2)) ||
- PyList_Append(py_retval, entry) < 0) {
- Py_XDECREF(entry);
+ if (!(entry = PyList_New(2)))
goto error;
- }
- if (!(value = libvirt_constcharPtrWrap(&labels[i].label[0])) ||
- PyList_SetItem(entry, 0, value) < 0) {
- Py_XDECREF(value);
- goto error;
- }
+ VIR_PY_LIST_APPEND_GOTO(py_retval, entry, error);
- if (!(value = libvirt_boolWrap(labels[i].enforcing)) ||
- PyList_SetItem(entry, 1, value) < 0) {
- Py_XDECREF(value);
- goto error;
- }
+ VIR_PY_LIST_SET_GOTO(entry, 0,
+ libvirt_constcharPtrWrap(&labels[i].label[0]),
+ error);
+ VIR_PY_LIST_SET_GOTO(entry, 1,
+ libvirt_boolWrap(labels[i].enforcing), error);
}
cleanup:
@@ -3006,16 +3023,20 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
+ if (names)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
I perhaps would have kept the open/close paren's here. I could have
missed others before here, this just jumped out at me. If it was just
"if (foo) bar;", then fine, but this is "if (foo) for (cond) bar", so
there's 3 lines...
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
@@ -3057,16 +3078,19 @@ libvirt_virConnectListDefinedNetworks(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
- for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -3097,16 +3121,9 @@ libvirt_virConnectListAllNetworks(PyObject *self
ATTRIBUTE_UNUSED,
if (!(py_retval = PyList_New(c_retval)))
goto cleanup;
- for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNetworkPtrWrap(nets[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
- /* python steals the pointer */
- nets[i] = NULL;
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virNetworkPtrWrap(nets[i]), error);
build issue - 'tmp' no longer necessary
cleanup:
for (i = 0; i < c_retval; i++)
@@ -3114,6 +3131,10 @@ libvirt_virConnectListAllNetworks(PyObject *self
ATTRIBUTE_UNUSED,
virNetworkFree(nets[i]);
VIR_FREE(nets);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -3278,14 +3299,17 @@ libvirt_virNodeGetCellsFreeMemory(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- for (i = 0; i < c_retval; i++) {
- PyList_SetItem(py_retval, i,
- libvirt_ulonglongWrap(freeMems[i]));
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_ulonglongWrap(freeMems[i]), error);
cleanup:
VIR_FREE(freeMems);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
static PyObject *
@@ -3455,16 +3479,19 @@ libvirt_virConnectListStoragePools(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
- for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ for (i = 0; i < c_retval; i++)
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
@@ -3507,7 +3534,8 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self
ATTRIBUTE_UNUSED,
if (names) {
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
}
cleanup:
@@ -3516,6 +3544,10 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self
ATTRIBUTE_UNUSED,
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -3547,12 +3579,8 @@ libvirt_virConnectListAllStoragePools(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virStoragePoolPtrWrap(pools[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virStoragePoolPtrWrap(pools[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
pools[i] = NULL;
}
@@ -3563,6 +3591,10 @@ libvirt_virConnectListAllStoragePools(PyObject *self
ATTRIBUTE_UNUSED,
virStoragePoolFree(pools[i]);
VIR_FREE(pools);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -3604,17 +3636,22 @@ libvirt_virStoragePoolListVolumes(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
+ if (names)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
- for (i = 0; i < c_retval; i++)
- VIR_FREE(names[i]);
- VIR_FREE(names);
-
+ if (names) {
+ for (i = 0; i < c_retval; i++)
+ VIR_FREE(names[i]);
+ VIR_FREE(names);
+ }
Ohhh - this perhaps make a previous comment unimportant, but certainly
shows why I mentioned it. Please just check other changes to make sure
a similar construct is not necessary
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -3647,12 +3684,8 @@ libvirt_virStoragePoolListAllVolumes(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virStorageVolPtrWrap(vols[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virStorageVolPtrWrap(vols[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
vols[i] = NULL;
}
@@ -3663,6 +3696,10 @@ libvirt_virStoragePoolListAllVolumes(PyObject *self
ATTRIBUTE_UNUSED,
virStorageVolFree(vols[i]);
VIR_FREE(vols);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -3714,14 +3751,20 @@ libvirt_virStoragePoolGetInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(4)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.state));
- PyList_SetItem(py_retval, 1,
- libvirt_ulonglongWrap(info.capacity));
- PyList_SetItem(py_retval, 2,
- libvirt_ulonglongWrap(info.allocation));
- PyList_SetItem(py_retval, 3,
- libvirt_ulonglongWrap(info.available));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_intWrap((int) info.state), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_ulonglongWrap(info.capacity), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.allocation), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 3,
+ libvirt_ulonglongWrap(info.available), error);
+
return py_retval;
+
+ error:
+ Py_XDECREF(py_retval);
+ return NULL;
}
@@ -3748,12 +3791,18 @@ libvirt_virStorageVolGetInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(3)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
- PyList_SetItem(py_retval, 1,
- libvirt_ulonglongWrap(info.capacity));
- PyList_SetItem(py_retval, 2,
- libvirt_ulonglongWrap(info.allocation));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_intWrap((int) info.type), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_ulonglongWrap(info.capacity), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.allocation), error);
+
return py_retval;
+
+ error:
+ Py_DECREF(py_retval);
+ return NULL;
}
static PyObject *
@@ -3873,16 +3922,20 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
+ if (names)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -3914,12 +3967,8 @@ libvirt_virConnectListAllNodeDevices(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNodeDevicePtrWrap(devices[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virNodeDevicePtrWrap(devices[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
devices[i] = NULL;
}
@@ -3930,6 +3979,10 @@ libvirt_virConnectListAllNodeDevices(PyObject *self
ATTRIBUTE_UNUSED,
virNodeDeviceFree(devices[i]);
VIR_FREE(devices);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -3969,16 +4022,20 @@ libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
+ if (names)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
static PyObject *
@@ -4096,7 +4153,8 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
if (uuids) {
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(uuids[i]), error);
}
cleanup:
@@ -4104,6 +4162,10 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
VIR_FREE(uuids[i]);
VIR_FREE(uuids);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -4135,12 +4197,8 @@ libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virSecretPtrWrap(secrets[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virSecretPtrWrap(secrets[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
secrets[i] = NULL;
}
@@ -4151,6 +4209,10 @@ libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
virSecretFree(secrets[i]);
VIR_FREE(secrets);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -4323,16 +4385,20 @@ libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (uuids) {
+ if (uuids)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(uuids[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(uuids[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(uuids[i]);
VIR_FREE(uuids);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#if LIBVIR_CHECK_VERSION(0, 10, 2)
@@ -4364,12 +4430,8 @@ libvirt_virConnectListAllNWFilters(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virNWFilterPtrWrap(filters[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virNWFilterPtrWrap(filters[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
filters[i] = NULL;
}
@@ -4380,6 +4442,10 @@ libvirt_virConnectListAllNWFilters(PyObject *self
ATTRIBUTE_UNUSED,
virNWFilterFree(filters[i]);
VIR_FREE(filters);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -4422,16 +4488,20 @@ libvirt_virConnectListInterfaces(PyObject *self
ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(c_retval)) == NULL)
goto cleanup;
- if (names) {
+ if (names)
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
cleanup:
for (i = 0; i < c_retval; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
@@ -4476,7 +4546,8 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self
ATTRIBUTE_UNUSED,
if (names) {
for (i = 0; i < c_retval; i++)
- PyList_SetItem(py_retval, i, libvirt_constcharPtrWrap(names[i]));
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_constcharPtrWrap(names[i]), error);
}
cleanup:
@@ -4484,6 +4555,10 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self
ATTRIBUTE_UNUSED,
VIR_FREE(names[i]);
VIR_FREE(names);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
@@ -4516,12 +4591,8 @@ libvirt_virConnectListAllInterfaces(PyObject *self
ATTRIBUTE_UNUSED,
goto cleanup;
for (i = 0; i < c_retval; i++) {
- if (!(tmp = libvirt_virInterfacePtrWrap(ifaces[i])) ||
- PyList_SetItem(py_retval, i, tmp) < 0) {
- Py_XDECREF(tmp);
- Py_CLEAR(py_retval);
- goto cleanup;
- }
+ VIR_PY_LIST_SET_GOTO(py_retval, i,
+ libvirt_virInterfacePtrWrap(ifaces[i]), error);
build issue - 'tmp' no longer necessary
/* python steals the pointer */
ifaces[i] = NULL;
}
@@ -4532,6 +4603,10 @@ libvirt_virConnectListAllInterfaces(PyObject *self
ATTRIBUTE_UNUSED,
virInterfaceFree(ifaces[i]);
VIR_FREE(ifaces);
return py_retval;
+
+ error:
+ Py_CLEAR(py_retval);
+ goto cleanup;
}
#endif /* LIBVIR_CHECK_VERSION(0, 10, 2) */
@@ -4612,20 +4687,36 @@ libvirt_virDomainGetJobInfo(PyObject *self ATTRIBUTE_UNUSED,
if ((py_retval = PyList_New(12)) == NULL)
return NULL;
- PyList_SetItem(py_retval, 0, libvirt_intWrap((int) info.type));
- PyList_SetItem(py_retval, 1, libvirt_ulonglongWrap(info.timeElapsed));
- PyList_SetItem(py_retval, 2, libvirt_ulonglongWrap(info.timeRemaining));
- PyList_SetItem(py_retval, 3, libvirt_ulonglongWrap(info.dataTotal));
- PyList_SetItem(py_retval, 4, libvirt_ulonglongWrap(info.dataProcessed));
- PyList_SetItem(py_retval, 5, libvirt_ulonglongWrap(info.dataRemaining));
- PyList_SetItem(py_retval, 6, libvirt_ulonglongWrap(info.memTotal));
- PyList_SetItem(py_retval, 7, libvirt_ulonglongWrap(info.memProcessed));
- PyList_SetItem(py_retval, 8, libvirt_ulonglongWrap(info.memRemaining));
- PyList_SetItem(py_retval, 9, libvirt_ulonglongWrap(info.fileTotal));
- PyList_SetItem(py_retval, 10, libvirt_ulonglongWrap(info.fileProcessed));
- PyList_SetItem(py_retval, 11, libvirt_ulonglongWrap(info.fileRemaining));
+ VIR_PY_LIST_SET_GOTO(py_retval, 0,
+ libvirt_intWrap((int) info.type), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 1,
+ libvirt_ulonglongWrap(info.timeElapsed), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 2,
+ libvirt_ulonglongWrap(info.timeRemaining), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 3,
+ libvirt_ulonglongWrap(info.dataTotal), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 4,
+ libvirt_ulonglongWrap(info.dataProcessed), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 5,
+ libvirt_ulonglongWrap(info.dataRemaining), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 6,
+ libvirt_ulonglongWrap(info.memTotal), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 7,
+ libvirt_ulonglongWrap(info.memProcessed), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 8,
+ libvirt_ulonglongWrap(info.memRemaining), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 9,
+ libvirt_ulonglongWrap(info.fileTotal), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 10,
+ libvirt_ulonglongWrap(info.fileProcessed), error);
+ VIR_PY_LIST_SET_GOTO(py_retval, 11,
+ libvirt_ulonglongWrap(info.fileRemaining), error);
return py_retval;
+
+ error:
+ Py_DECREF(py_retval);
+ return NULL;
}
#if LIBVIR_CHECK_VERSION(1, 0, 3)
@@ -4984,10 +5075,7 @@ libvirt_virDomainInterfaceAddresses(PyObject *self
ATTRIBUTE_UNUSED,
if (!py_addr)
goto error;
- if (PyList_SetItem(py_addrs, j, py_addr) < 0) {
- Py_DECREF(py_addr);
- goto error;
- }
+ VIR_PY_LIST_SET_GOTO(py_addrs, j, py_addr, error);
if ((py_iname = libvirt_constcharPtrWrap("addr")) == NULL ||
(py_ivalue = libvirt_constcharPtrWrap(addr->addr)) == NULL ||
@@ -6114,7 +6202,7 @@ libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn
ATTRIBUTE_UNUSE
if (pair == NULL)
goto cleanup;
- PyList_SetItem(pyobj_subject, i, pair);
+ VIR_PY_LIST_SET_GOTO(pyobj_subject, i, pair, cleanup);
VIR_PY_TUPLE_SET_GOTO(pair, 0,
libvirt_constcharPtrWrap(subject->identities[i].type),
@@ -7682,12 +7770,9 @@ libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED,
VIR_PY_TUPLE_SET_GOTO(ret, 1, pycpumap, error);
- for (i = 0; i < i_retval; i++) {
- if ((pyused = PyBool_FromLong(VIR_CPU_USED(cpumap, i))) == NULL)
- goto error;
- if (PyList_SetItem(pycpumap, i, pyused) < 0)
- goto error;
- }
+ for (i = 0; i < i_retval; i++)
+ VIR_PY_LIST_SET_GOTO(pycpumap, i,
+ PyBool_FromLong(VIR_CPU_USED(cpumap, i)), error);
build issue - 'pyused' no longer needed
John
/* 2: number of online CPUs */
VIR_PY_TUPLE_SET_GOTO(ret, 2, libvirt_uintWrap(online), error);
@@ -8143,8 +8228,7 @@ libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
if ((py_lease = PyDict_New()) == NULL)
goto error;
- if (PyList_SetItem(py_retval, i, py_lease) < 0)
- goto error;
+ VIR_PY_LIST_SET_GOTO(py_retval, i, py_lease, error);
#define VIR_SET_LEASE_ITEM(NAME, VALUE_OBJ_FUNC) \
do { \
@@ -8207,11 +8291,8 @@ convertDomainStatsRecord(virDomainStatsRecordPtr *records,
if (!(py_record = PyTuple_New(2)))
goto error;
- if (PyList_SetItem(py_retval, i, py_record) < 0)
- goto error;
+ VIR_PY_LIST_SET_GOTO(py_retval, i, py_record, error);
- /* libvirt_virDomainPtrWrap steals the object */
- virDomainRef(records[i]->dom);
VIR_PY_TUPLE_SET_GOTO(py_record, 0,
libvirt_virDomainPtrWrap(records[i]->dom),
error);
@@ -8453,7 +8534,7 @@ libvirt_virDomainGetFSInfo(PyObject *self ATTRIBUTE_UNUSED,
if (info == NULL)
goto error;
- PyList_SetItem(py_retval, i, info);
+ VIR_PY_LIST_SET_GOTO(py_retval, i, info, error);
VIR_PY_TUPLE_SET_GOTO(info, 0,
libvirt_constcharPtrWrap(fs->mountpoint), error);
@@ -8468,9 +8549,9 @@ libvirt_virDomainGetFSInfo(PyObject *self ATTRIBUTE_UNUSED,
VIR_PY_TUPLE_SET_GOTO(info, 3, alias, error);
for (j = 0; j < fs->ndevAlias; j++)
- if (PyList_Append(alias,
- libvirt_constcharPtrWrap(fs->devAlias[j])) < 0)
- goto error;
+ VIR_PY_LIST_APPEND_GOTO(alias,
+ libvirt_constcharPtrWrap(fs->devAlias[j]),
+ error);
}
cleanup: