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

Re: [libvirt] [PATCH 25/32] Convert 'int i' to 'size_t i' in src/network/ files



On 07/08/2013 10:21 PM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange redhat com>

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 redhat com>
---
  src/network/bridge_driver.c | 281 +++++++++++++++++++++++---------------------
  1 file changed, 144 insertions(+), 137 deletions(-)


@@ -3757,7 +3762,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
      unsigned int num_virt_fns = 0;
      char **vfname = NULL;
      virPCIDeviceAddressPtr *virt_fns;
-    int ret = -1, ii = 0;
+    int ret = -1, i = 0;

i is supposed to be type size_t here, isn't?

if ((virNetDevGetVirtualFunctions(netdef->forward.pfs->dev,
                                        &vfname, &virt_fns, &num_virt_fns)) < 0) {
@@ -3781,14 +3786,14 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
netdef->forward.nifs = num_virt_fns; - for (ii = 0; ii < netdef->forward.nifs; ii++) {
+    for (i = 0; i < netdef->forward.nifs; i++) {
          if ((netdef->forward.type == VIR_NETWORK_FORWARD_BRIDGE) ||
              (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE) ||
              (netdef->forward.type == VIR_NETWORK_FORWARD_VEPA) ||
              (netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH)) {
-            netdef->forward.ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
-            if (vfname[ii]) {
-                if (VIR_STRDUP(netdef->forward.ifs[ii].device.dev, vfname[ii]) < 0)
+            netdef->forward.ifs[i].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV;
+            if (vfname[i]) {
+                if (VIR_STRDUP(netdef->forward.ifs[i].device.dev, vfname[i]) < 0)
                      goto finish;
              } else {
                  virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3798,19 +3803,19 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) {
          }
          else if (netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) {
              /* VF's are always PCI devices */
-            netdef->forward.ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI;
-            netdef->forward.ifs[ii].device.pci.domain = virt_fns[ii]->domain;
-            netdef->forward.ifs[ii].device.pci.bus = virt_fns[ii]->bus;
-            netdef->forward.ifs[ii].device.pci.slot = virt_fns[ii]->slot;
-            netdef->forward.ifs[ii].device.pci.function = virt_fns[ii]->function;
+            netdef->forward.ifs[i].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI;
+            netdef->forward.ifs[i].device.pci.domain = virt_fns[i]->domain;
+            netdef->forward.ifs[i].device.pci.bus = virt_fns[i]->bus;
+            netdef->forward.ifs[i].device.pci.slot = virt_fns[i]->slot;
+            netdef->forward.ifs[i].device.pci.function = virt_fns[i]->function;
          }
      }
ret = 0;
  finish:
-    for (ii = 0; ii < num_virt_fns; ii++) {
-        VIR_FREE(vfname[ii]);
-        VIR_FREE(virt_fns[ii]);
+    for (i = 0; i < num_virt_fns; i++) {
+        VIR_FREE(vfname[i]);
+        VIR_FREE(virt_fns[i]);
      }
      VIR_FREE(vfname);
      VIR_FREE(virt_fns);

missed networkConnectNumOfNetworks()
            networkConnectListNetworks()
            networkConnectNumOfDefinedNetworks()
            networkConnectListDefinedNetworks()

Guannan


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