[PATCH 30/32] Convert 'int i' to 'size_t i' in python/ files

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int' or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 python/libvirt-lxc-override.c |   2 +-
 python/libvirt-override.c     | 111 ++++++++++++++++++++++++++----------------
 2 files changed, 69 insertions(+), 44 deletions(-)

diff --git a/python/libvirt-lxc-override.c b/python/libvirt-lxc-override.c
index c69affc..73685df 100644
--- a/python/libvirt-lxc-override.c
+++ b/python/libvirt-lxc-override.c
@@ -64,7 +64,7 @@ libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
     unsigned int flags;
     int c_retval;
     int *fdlist = NULL;
-    int i;
+    size_t i;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainLxcOpenNamespace",
                           &pyobj_domain, &flags))
diff --git a/python/libvirt-override.c b/python/libvirt-override.c
index 5c5586d..fcdc91b 100644
--- a/python/libvirt-override.c
+++ b/python/libvirt-override.c
@@ -76,7 +76,7 @@ static PyObject *
 getPyVirTypedParameter(const virTypedParameterPtr params, int nparams)
 {
     PyObject *key, *val, *info;
-    int i;
+    size_t i;
 
     if ((info = PyDict_New()) == NULL)
         return NULL;
@@ -159,7 +159,7 @@ setPyVirTypedParameter(PyObject *info,
 #endif
     virTypedParameterPtr temp = NULL, ret = NULL;
     Py_ssize_t size;
-    int i;
+    size_t i;
 
     if ((size = PyDict_Size(info)) < 0)
         return NULL;
@@ -287,7 +287,7 @@ virPyDictToTypedParams(PyObject *dict,
     Py_ssize_t pos = 0;
 #endif
     virTypedParameterPtr params = NULL;
-    int i;
+    size_t i;
     int n = 0;
     int max = 0;
     int ret = -1;
@@ -540,7 +540,8 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
     PyObject *error = NULL;
     int ncpus = -1, start_cpu = 0;
     int sumparams = 0, nparams = -1;
-    int i, i_retval;
+    size_t i;
+    int i_retval;
     unsigned int flags;
     bool totalflag;
     virTypedParameterPtr params = NULL, cpuparams;
@@ -704,7 +705,8 @@ static PyObject *
 libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
     virDomainPtr domain;
     PyObject *pyobj_domain;
-    unsigned int nr_stats, i;
+    unsigned int nr_stats;
+    size_t i;
     virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
     PyObject *info;
 
@@ -1597,7 +1599,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
     }
     for (i = 0; i < dominfo.nrVirtCpu; i++) {
         PyObject *info = PyTuple_New(cpunum);
-        int j;
+        size_t j;
         if (info == NULL)
             goto cleanup;
         for (j = 0; j < cpunum; j++) {
@@ -1641,7 +1643,8 @@ libvirt_virDomainPinVcpu(PyObject *self ATTRIBUTE_UNUSED,
     PyObject *pyobj_domain, *pycpumap;
     PyObject *ret = NULL;
     unsigned char *cpumap;
-    int cpumaplen, i, vcpu, tuple_size, cpunum;
+    int cpumaplen, vcpu, tuple_size, cpunum;
+    size_t i;
     int i_retval;
 
     if (!PyArg_ParseTuple(args, (char *)"OiO:virDomainPinVcpu",
@@ -1704,7 +1707,8 @@ libvirt_virDomainPinVcpuFlags(PyObject *self ATTRIBUTE_UNUSED,
     PyObject *pyobj_domain, *pycpumap;
     PyObject *ret = NULL;
     unsigned char *cpumap;
-    int cpumaplen, i, vcpu, tuple_size, cpunum;
+    int cpumaplen, vcpu, tuple_size, cpunum;
+    size_t i;
     unsigned int flags;
     int i_retval;
 
@@ -1831,7 +1835,8 @@ libvirt_virDomainPinEmulator(PyObject *self ATTRIBUTE_UNUSED,
     virDomainPtr domain;
     PyObject *pyobj_domain, *pycpumap;
     unsigned char *cpumap = NULL;
-    int cpumaplen, i, tuple_size, cpunum;
+    int cpumaplen, tuple_size, cpunum;
+    size_t i;
     int i_retval;
     unsigned int flags;
 
@@ -2187,7 +2192,7 @@ libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED, PyObject *args) {
 
     auth.ncredtype = PyList_Size(pycredtype);
     if (auth.ncredtype) {
-        int i;
+        size_t i;
         if (VIR_ALLOC_N(auth.credtype, auth.ncredtype) < 0)
             return VIR_PY_NONE;
         for (i = 0; i < auth.ncredtype; i++) {
@@ -2300,7 +2305,8 @@ static PyObject *
 libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
                                 PyObject *args) {
     PyObject *py_retval;
-    int *ids = NULL, c_retval, i;
+    int *ids = NULL, c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -2349,7 +2355,7 @@ libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virDomainPtr *doms = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllDomains",
@@ -2391,7 +2397,8 @@ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
                                      PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -2436,7 +2443,8 @@ libvirt_virDomainSnapshotListNames(PyObject *self ATTRIBUTE_UNUSED,
 {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virDomainPtr dom;
     PyObject *pyobj_dom;
     PyObject *pyobj_snap;
@@ -2492,7 +2500,8 @@ libvirt_virDomainListAllSnapshots(PyObject *self ATTRIBUTE_UNUSED,
 {
     PyObject *py_retval = NULL;
     virDomainSnapshotPtr *snaps = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virDomainPtr dom;
     PyObject *pyobj_dom;
     unsigned int flags;
@@ -2537,7 +2546,8 @@ libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
 {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virDomainSnapshotPtr snap;
     PyObject *pyobj_snap;
     unsigned int flags;
@@ -2591,7 +2601,8 @@ libvirt_virDomainSnapshotListAllChildren(PyObject *self ATTRIBUTE_UNUSED,
 {
     PyObject *py_retval = NULL;
     virDomainSnapshotPtr *snaps = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virDomainSnapshotPtr parent;
     PyObject *pyobj_parent;
     unsigned int flags;
@@ -2870,7 +2881,8 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
                                PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -2915,7 +2927,8 @@ libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
                                       PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -2964,7 +2977,7 @@ libvirt_virConnectListAllNetworks(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virNetworkPtr *nets = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNetworks",
@@ -3128,7 +3141,8 @@ libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED, PyObject *arg
 {
     PyObject *py_retval;
     PyObject *pyobj_conn;
-    int startCell, maxCells, c_retval, i;
+    int startCell, maxCells, c_retval;
+    size_t i;
     virConnectPtr conn;
     unsigned long long *freeMems;
 
@@ -3168,7 +3182,8 @@ libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
     PyObject *pyobj_conn;
     virConnectPtr conn;
     unsigned int flags;
-    int cpuNum, c_retval, i;
+    int cpuNum, c_retval;
+    size_t i;
     int nparams = 0;
     virNodeCPUStatsPtr stats = NULL;
 
@@ -3231,7 +3246,8 @@ libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED, PyObject *args)
     PyObject *pyobj_conn;
     virConnectPtr conn;
     unsigned int flags;
-    int cellNum, c_retval, i;
+    int cellNum, c_retval;
+    size_t i;
     int nparams = 0;
     virNodeMemoryStatsPtr stats = NULL;
 
@@ -3290,7 +3306,8 @@ libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
                                    PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -3343,7 +3360,8 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
                                           PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -3400,7 +3418,7 @@ libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virStoragePoolPtr *pools = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllStoragePools",
@@ -3442,7 +3460,8 @@ libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
                                   PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virStoragePoolPtr pool;
     PyObject *pyobj_pool;
 
@@ -3498,7 +3517,7 @@ libvirt_virStoragePoolListAllVolumes(PyObject *self ATTRIBUTE_UNUSED,
     virStoragePoolPtr pool;
     virStorageVolPtr *vols = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
     PyObject *pyobj_pool;
 
@@ -3701,7 +3720,8 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
                            PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
     char *cap;
@@ -3752,7 +3772,7 @@ libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virNodeDevicePtr *devices = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNodeDevices",
@@ -3794,7 +3814,8 @@ libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
                               PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virNodeDevicePtr dev;
     PyObject *pyobj_dev;
 
@@ -3914,7 +3935,8 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
     PyObject *py_retval;
     char **uuids = NULL;
     virConnectPtr conn;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     PyObject *pyobj_conn;
 
     if (!PyArg_ParseTuple(args, (char *)"O:virConnectListSecrets", &pyobj_conn))
@@ -3961,7 +3983,7 @@ libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virSecretPtr *secrets = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllSecrets",
@@ -4133,7 +4155,8 @@ libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
     PyObject *py_retval;
     char **uuids = NULL;
     virConnectPtr conn;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     PyObject *pyobj_conn;
 
     if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNWFilters", &pyobj_conn))
@@ -4180,7 +4203,7 @@ libvirt_virConnectListAllNWFilters(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virNWFilterPtr *filters = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllNWFilters",
@@ -4222,7 +4245,8 @@ libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
                                  PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -4275,7 +4299,8 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
                                         PyObject *args) {
     PyObject *py_retval;
     char **names = NULL;
-    int c_retval, i;
+    int c_retval;
+    size_t i;
     virConnectPtr conn;
     PyObject *pyobj_conn;
 
@@ -4334,7 +4359,7 @@ libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED,
     virConnectPtr conn;
     virInterfacePtr *ifaces = NULL;
     int c_retval = 0;
-    int i;
+    size_t i;
     unsigned int flags;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virConnectListAllInterfaces",
@@ -4389,7 +4414,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
     conn = (virConnectPtr) PyvirConnect_Get(pyobj_conn);
 
     if (PyList_Check(list)) {
-        int i;
+        size_t i;
 
         ncpus = PyList_Size(list);
         if (VIR_ALLOC_N(xmlcpus, ncpus) < 0)
@@ -4669,7 +4694,7 @@ libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
     virDomainDiskErrorPtr disks = NULL;
     unsigned int ndisks;
     int count;
-    int i;
+    size_t i;
 
     if (!PyArg_ParseTuple(args, (char *) "Oi:virDomainGetDiskErrors",
                           &pyobj_domain, &flags))
@@ -5773,7 +5798,7 @@ libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSE
     PyObject *pyobj_remote;
     PyObject *pyobj_subject;
     int ret = -1;
-    int i;
+    size_t i;
 
     LIBVIRT_ENSURE_THREAD_STATE;
 
@@ -6561,7 +6586,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
     int holdtime;
     unsigned int flags;
     int ret;
-    int i;
+    size_t i;
     unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
     unsigned int nkeycodes;
 
@@ -6920,7 +6945,7 @@ libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED,
     unsigned char *cpumap = NULL;
     unsigned int online = 0;
     unsigned int flags;
-    int i;
+    size_t i;
 
     if (!PyArg_ParseTuple(args, (char *)"Oi:virNodeGetCPUMap",
                           &pyobj_conn, &flags))
-- 
1.8.1.4

--
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]