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

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



On Tue, Jul 09, 2013 at 07:19:09PM +0800, Guannan Ren wrote:
> 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/util/virbitmap.c             | 13 +++++++------
> >  src/util/vircgroup.c             | 32 ++++++++++++++++----------------
> >  src/util/vircommand.c            | 10 +++++-----
> >  src/util/virdnsmasq.c            | 16 ++++++++--------
> >  src/util/virebtables.c           |  8 ++++----
> >  src/util/vireventpoll.c          | 28 ++++++++++++++--------------
> >  src/util/virhook.c               |  3 ++-
> >  src/util/virjson.c               | 12 ++++++------
> >  src/util/virkeycode.c            |  4 ++--
> >  src/util/virlog.c                | 30 +++++++++++++++---------------
> >  src/util/virlog.h                |  2 +-
> >  src/util/virmacaddr.c            |  2 +-
> >  src/util/virnetdevmacvlan.c      |  2 +-
> >  src/util/virnetdevopenvswitch.c  |  2 +-
> >  src/util/virnetdevtap.c          |  4 ++--
> >  src/util/virnetdevvportprofile.c |  2 +-
> >  src/util/virnetlink.c            | 14 ++++++++------
> >  src/util/virnuma.c               | 13 +++++++------
> >  src/util/virpci.c                | 14 +++++++-------
> >  src/util/virportallocator.c      |  8 ++++----
> >  src/util/virprocess.c            |  7 ++++---
> >  src/util/virscsi.c               |  6 +++---
> >  src/util/virsocketaddr.c         | 28 ++++++++++++++--------------
> >  src/util/virstoragefile.c        |  7 ++++---
> >  src/util/virstring.c             |  3 ++-
> >  src/util/virsysinfo.c            |  6 +++---
> >  src/util/virthreadwin32.c        |  6 +++---
> >  src/util/virthreadwin32.h        |  2 +-
> >  src/util/virtypedparam.c         | 10 +++++-----
> >  src/util/viruri.c                |  2 +-
> >  src/util/virusb.c                |  6 +++---
> >  src/util/virutil.c               | 29 ++++++++++++++++-------------
> >  src/util/viruuid.c               |  7 ++++---
> >  33 files changed, 175 insertions(+), 163 deletions(-)
> 
> ...

> 
> virPCIGetVirtualFunctionIndex() is missing

The following will be squashed in


diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index cd1430c..3529f1a 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -392,7 +392,7 @@ static int
 virExec(virCommandPtr cmd)
 {
     pid_t pid;
-    int null = -1, i, openmax;
+    int null = -1, fd, openmax;
     int pipeout[2] = {-1,-1};
     int pipeerr[2] = {-1,-1};
     int childin = cmd->infd;
@@ -511,15 +511,15 @@ virExec(virCommandPtr cmd)
     }
 
     openmax = sysconf(_SC_OPEN_MAX);
-    for (i = 3; i < openmax; i++) {
-        if (i == childin || i == childout || i == childerr)
+    for (fd = 3; fd < openmax; fd++) {
+        if (fd == childin || fd == childout || fd == childerr)
             continue;
         if (!cmd->preserve ||
-            !virCommandFDIsSet(i, cmd->preserve, cmd->preserve_size)) {
-            tmpfd = i;
+            !virCommandFDIsSet(fd, cmd->preserve, cmd->preserve_size)) {
+            tmpfd = fd;
             VIR_MASS_CLOSE(tmpfd);
-        } else if (virSetInherit(i, true) < 0) {
-            virReportSystemError(errno, _("failed to preserve fd %d"), i);
+        } else if (virSetInherit(fd, true) < 0) {
+            virReportSystemError(errno, _("failed to preserve fd %d"), fd);
             goto fork_error;
         }
     }
diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index 1b76737..aaa276d 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -1078,7 +1078,8 @@ virNetDevGetVirtualFunctions(const char *pfname,
                              virPCIDeviceAddressPtr **virt_fns,
                              unsigned int *n_vfname)
 {
-    int ret = -1, i;
+    int ret = -1;
+    size_t i;
     char *pf_sysfs_device_link = NULL;
     char *pci_sysfs_device_link = NULL;
     char *pciConfigAddr = NULL;
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index 4ff6b24..ae9276c 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -511,14 +511,14 @@ int virNetDevBridgeGetSTPDelay(const char *brname,
     int fd = -1;
     int ret = -1;
     struct ifreq ifr;
-    unsigned long i;
+    unsigned long val;
 
     if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
         goto cleanup;
 
-    ret = virNetDevBridgeGet(brname, "forward_delay", &i,
+    ret = virNetDevBridgeGet(brname, "forward_delay", &val,
                              fd, &ifr);
-    *delayms = JIFFIES_TO_MS(i);
+    *delayms = JIFFIES_TO_MS(val);
 
 cleanup:
     VIR_FORCE_CLOSE(fd);
@@ -571,14 +571,14 @@ int virNetDevBridgeGetSTP(const char *brname,
     int fd = -1;
     int ret = -1;
     struct ifreq ifr;
-    unsigned long i;
+    unsigned long val;
 
     if ((fd = virNetDevSetupControl(brname, &ifr)) < 0)
         goto cleanup;
 
-    ret = virNetDevBridgeGet(brname, "stp_state", &i,
+    ret = virNetDevBridgeGet(brname, "stp_state", &val,
                              fd, &ifr);
-    *enabled = i ? true : false;
+    *enabled = val ? true : false;
 
 cleanup:
     VIR_FORCE_CLOSE(fd);
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 360e335..d7ebeac 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -2476,7 +2476,8 @@ virPCIGetVirtualFunctionIndex(const char *pf_sysfs_device_link,
                               const char *vf_sysfs_device_link,
                               int *vf_index)
 {
-    int ret = -1, i;
+    int ret = -1;
+    size_t i;
     unsigned int num_virt_fns = 0;
     virPCIDeviceAddressPtr vf_bdf = NULL;
     virPCIDeviceAddressPtr *virt_fns = NULL;
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index caf8bc0..3e01baf 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -585,7 +585,8 @@ int virSocketAddrCheckNetmask(virSocketAddrPtr addr1, virSocketAddrPtr addr2,
  * Returns the size of the range or -1 in case of failure
  */
 int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr end) {
-    int ret = 0, i;
+    int ret = 0;
+    size_t i;
 
     if ((start == NULL) || (end == NULL))
         return -1;

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


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