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

[libvirt] [PATCH libvirt-python 07/17] Remove use of VIR_ALLOC_N



From: "Daniel P. Berrange" <berrange redhat com>

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 libvirt-override.c | 106 ++++++++++++++++++++++++++---------------------------
 1 file changed, 53 insertions(+), 53 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index 70aaf24..a8cf71d 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -169,7 +169,7 @@ setPyVirTypedParameter(PyObject *info,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(ret, size) < 0) {
+    if (!(ret = malloc(sizeof(*ret) * size))) {
         PyErr_NoMemory();
         return NULL;
     }
@@ -508,7 +508,7 @@ libvirt_virDomainBlockStatsFlags(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -575,7 +575,7 @@ libvirt_virDomainGetCPUStats(PyObject *self, PyObject *args)
 
         sumparams = nparams * MIN(ncpus, 128);
 
-        if (VIR_ALLOC_N_QUIET(params, sumparams) < 0) {
+        if (!(params = malloc(sizeof(*params) * sumparams))) {
             error = PyErr_NoMemory();
             goto error;
         }
@@ -627,7 +627,7 @@ libvirt_virDomainGetCPUStats(PyObject *self, PyObject *args)
         if (nparams) {
             sumparams = nparams;
 
-            if (VIR_ALLOC_N_QUIET(params, nparams) < 0) {
+            if (!(params = malloc(sizeof(*params) * nparams))) {
                 error = PyErr_NoMemory();
                 goto error;
             }
@@ -808,7 +808,7 @@ libvirt_virDomainGetSchedulerParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -856,7 +856,7 @@ libvirt_virDomainGetSchedulerParametersFlags(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -916,7 +916,7 @@ libvirt_virDomainSetSchedulerParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -992,7 +992,7 @@ libvirt_virDomainSetSchedulerParametersFlags(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1066,7 +1066,7 @@ libvirt_virDomainSetBlkioParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1126,7 +1126,7 @@ libvirt_virDomainGetBlkioParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1186,7 +1186,7 @@ libvirt_virDomainSetMemoryParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1246,7 +1246,7 @@ libvirt_virDomainGetMemoryParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1306,7 +1306,7 @@ libvirt_virDomainSetNumaParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1366,7 +1366,7 @@ libvirt_virDomainGetNumaParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1427,7 +1427,7 @@ libvirt_virDomainSetInterfaceParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1488,7 +1488,7 @@ libvirt_virDomainGetInterfaceParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1534,12 +1534,12 @@ libvirt_virDomainGetVcpus(PyObject *self,
     if (i_retval < 0)
         return VIR_PY_INT_FAIL;
 
-    if (VIR_ALLOC_N_QUIET(cpuinfo, dominfo.nrVirtCpu) < 0)
+    if (!(cpuinfo = malloc(sizeof(*cpuinfo) * dominfo.nrVirtCpu)))
         return PyErr_NoMemory();
 
     cpumaplen = VIR_CPU_MAPLEN(cpunum);
     if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
-        VIR_ALLOC_N_QUIET(cpumap, dominfo.nrVirtCpu * cpumaplen) < 0) {
+        !(cpumap = malloc(sizeof(*cpumap) * dominfo.nrVirtCpu * cpumaplen))) {
         error = PyErr_NoMemory();
         goto cleanup;
     }
@@ -1662,7 +1662,7 @@ libvirt_virDomainPinVcpu(PyObject *self,
     }
 
     cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
+    if (!(cpumap = malloc(sizeof(*cpumap) * cpumaplen)))
         return PyErr_NoMemory();
 
     for (i = 0; i < tuple_size; i++) {
@@ -1727,7 +1727,7 @@ libvirt_virDomainPinVcpuFlags(PyObject *self,
     }
 
     cpumaplen = VIR_CPU_MAPLEN(cpunum);
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
+    if (!(cpumap = malloc(sizeof(*cpumap) * cpumaplen)))
         return PyErr_NoMemory();
 
     for (i = 0; i < tuple_size; i++) {
@@ -1787,7 +1787,7 @@ libvirt_virDomainGetVcpuPinInfo(PyObject *self,
 
     cpumaplen = VIR_CPU_MAPLEN(cpunum);
     if (xalloc_oversized(dominfo.nrVirtCpu, cpumaplen) ||
-        VIR_ALLOC_N_QUIET(cpumaps, dominfo.nrVirtCpu * cpumaplen) < 0)
+        !(cpumaps = malloc(sizeof(*cpumaps) * dominfo.nrVirtCpu * cpumaplen)))
         goto cleanup;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -1856,7 +1856,7 @@ libvirt_virDomainPinEmulator(PyObject *self,
     if ((tuple_size = PyTuple_Size(pycpumap)) == -1)
         return NULL;
 
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
+    if (!(cpumap = malloc(sizeof(*cpumap) * cpumaplen)))
         return PyErr_NoMemory();
 
     for (i = 0; i < tuple_size; i++) {
@@ -1915,7 +1915,7 @@ libvirt_virDomainGetEmulatorPinInfo(PyObject *self,
 
     cpumaplen = VIR_CPU_MAPLEN(cpunum);
 
-    if (VIR_ALLOC_N_QUIET(cpumap, cpumaplen) < 0)
+    if (!(cpumap = malloc(sizeof(*cpumap) * cpumaplen)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -2191,7 +2191,7 @@ libvirt_virConnectOpenAuth(PyObject *self, PyObject *args) {
     auth.ncredtype = PyList_Size(pycredtype);
     if (auth.ncredtype) {
         size_t i;
-        if (VIR_ALLOC_N_QUIET(auth.credtype, auth.ncredtype) < 0)
+        if (!(auth.credtype = malloc(sizeof(*auth.credtype) * auth.ncredtype)))
             return VIR_PY_NONE;
         for (i = 0; i < auth.ncredtype; i++) {
             PyObject *val;
@@ -2320,7 +2320,7 @@ libvirt_virConnectListDomainsID(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(ids, c_retval) < 0)
+        if (!(ids = malloc(sizeof(*ids) * c_retval)))
             return VIR_PY_NONE;
 
         LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -2412,7 +2412,7 @@ libvirt_virConnectListDefinedDomains(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListDefinedDomains(conn, names, c_retval);
@@ -2460,7 +2460,7 @@ libvirt_virDomainSnapshotListNames(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return PyErr_NoMemory();
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virDomainSnapshotListNames(dom, names, c_retval, flags);
@@ -2562,7 +2562,7 @@ libvirt_virDomainSnapshotListChildrenNames(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return PyErr_NoMemory();
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virDomainSnapshotListChildrenNames(snap, names, c_retval,
@@ -2896,7 +2896,7 @@ libvirt_virConnectListNetworks(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListNetworks(conn, names, c_retval);
@@ -2942,7 +2942,7 @@ libvirt_virConnectListDefinedNetworks(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListDefinedNetworks(conn, names, c_retval);
@@ -3151,7 +3151,7 @@ libvirt_virNodeGetCellsFreeMemory(PyObject *self, PyObject *args)
         return VIR_PY_NONE;
 
     conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
-    if (VIR_ALLOC_N_QUIET(freeMems, maxCells) < 0)
+    if ((freeMems = malloc(sizeof(*freeMems) * maxCells)))
         return VIR_PY_NONE;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -3196,7 +3196,7 @@ libvirt_virNodeGetCPUStats(PyObject *self, PyObject *args)
         return VIR_PY_NONE;
 
     if (nparams) {
-        if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
+        if (!(stats = malloc(sizeof(*stats) * nparams)))
             return PyErr_NoMemory();
 
         LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -3260,7 +3260,7 @@ libvirt_virNodeGetMemoryStats(PyObject *self, PyObject *args)
         return VIR_PY_NONE;
 
     if (nparams) {
-        if (VIR_ALLOC_N_QUIET(stats, nparams) < 0)
+        if (!(stats = malloc(sizeof(*stats) * nparams)))
             return PyErr_NoMemory();
 
         LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -3321,7 +3321,7 @@ libvirt_virConnectListStoragePools(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListStoragePools(conn, names, c_retval);
@@ -3375,7 +3375,7 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListDefinedStoragePools(conn, names, c_retval);
@@ -3475,7 +3475,7 @@ libvirt_virStoragePoolListVolumes(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virStoragePoolListVolumes(pool, names, c_retval);
@@ -3737,7 +3737,7 @@ libvirt_virNodeListDevices(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virNodeListDevices(conn, cap, names, c_retval, flags);
@@ -3828,7 +3828,7 @@ libvirt_virNodeDeviceListCaps(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virNodeDeviceListCaps(dev, names, c_retval);
@@ -3948,7 +3948,7 @@ libvirt_virConnectListSecrets(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
+        if (!(uuids = malloc(sizeof(*uuids) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListSecrets(conn, uuids, c_retval);
@@ -4168,7 +4168,7 @@ libvirt_virConnectListNWFilters(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(uuids, c_retval) < 0)
+        if (!(uuids = malloc(sizeof(*uuids) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListNWFilters(conn, uuids, c_retval);
@@ -4260,7 +4260,7 @@ libvirt_virConnectListInterfaces(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListInterfaces(conn, names, c_retval);
@@ -4315,7 +4315,7 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self,
         return VIR_PY_NONE;
 
     if (c_retval) {
-        if (VIR_ALLOC_N_QUIET(names, c_retval) < 0)
+        if (!(names = malloc(sizeof(*names) * c_retval)))
             return VIR_PY_NONE;
         LIBVIRT_BEGIN_ALLOW_THREADS;
         c_retval = virConnectListDefinedInterfaces(conn, names, c_retval);
@@ -4415,7 +4415,7 @@ libvirt_virConnectBaselineCPU(PyObject *self,
         size_t i;
 
         ncpus = PyList_Size(list);
-        if (VIR_ALLOC_N_QUIET(xmlcpus, ncpus) < 0)
+        if (!(xmlcpus = malloc(sizeof(*xmlcpus) * ncpus)))
             return VIR_PY_INT_FAIL;
 
         for (i = 0; i < ncpus; i++) {
@@ -4625,7 +4625,7 @@ libvirt_virDomainSetBlockIoTune(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -4686,7 +4686,7 @@ libvirt_virDomainGetBlockIoTune(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -4729,7 +4729,7 @@ libvirt_virDomainGetDiskErrors(PyObject *self,
     ndisks = count;
 
     if (ndisks) {
-        if (VIR_ALLOC_N_QUIET(disks, ndisks) < 0)
+        if (!(disks = malloc(sizeof(*disks) * ndisks)))
             return VIR_PY_NONE;
 
         LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -6600,7 +6600,7 @@ libvirt_virStreamRecv(PyObject *self,
     }
     stream = PyvirStream_Get(pyobj_stream);
 
-    if (VIR_ALLOC_N_QUIET(buf, nbytes+1 > 0 ? nbytes+1 : 1) < 0)
+    if (!(buf = malloc(sizeof(*buf) * (nbytes+1 > 0 ? nbytes+1 : 1))))
         return VIR_PY_NONE;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -6826,7 +6826,7 @@ libvirt_virDomainBlockPeek(PyObject *self,
 
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
-    if (VIR_ALLOC_N_QUIET(buf, size) < 0)
+    if (!(buf = malloc(sizeof(*buf) * size)))
         return VIR_PY_NONE;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -6863,7 +6863,7 @@ libvirt_virDomainMemoryPeek(PyObject *self,
 
     domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain);
 
-    if (VIR_ALLOC_N_QUIET(buf, size) < 0)
+    if (!(buf = malloc(sizeof(*buf) * size)))
         return VIR_PY_NONE;
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -6923,7 +6923,7 @@ libvirt_virNodeSetMemoryParameters(PyObject *self,
         return NULL;
     }
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -6983,7 +6983,7 @@ libvirt_virNodeGetMemoryParameters(PyObject *self,
     if (!nparams)
         return PyDict_New();
 
-    if (VIR_ALLOC_N_QUIET(params, nparams) < 0)
+    if (!(params = malloc(sizeof(*params) * nparams)))
         return PyErr_NoMemory();
 
     LIBVIRT_BEGIN_ALLOW_THREADS;
@@ -7091,7 +7091,7 @@ libvirt_virDomainCreateWithFiles(PyObject *self, PyObject *args) {
 
     nfiles = PyList_Size(pyobj_files);
 
-    if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
+    if (!(files = malloc(sizeof(*files) * nfiles)))
         return PyErr_NoMemory();
 
     for (i = 0; i < nfiles; i++) {
@@ -7135,7 +7135,7 @@ libvirt_virDomainCreateXMLWithFiles(PyObject *self, PyObject *args) {
 
     nfiles = PyList_Size(pyobj_files);
 
-    if (VIR_ALLOC_N_QUIET(files, nfiles) < 0)
+    if (!(files = malloc(sizeof(*files) * nfiles)))
         return PyErr_NoMemory();
 
     for (i = 0; i < nfiles; i++) {
-- 
1.8.3.1


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