Re: [PATCH 26/32] Convert 'int i' to 'size_t i' in src/interface/ files

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

 



On Tue, Jul 09, 2013 at 03:36:02PM +0200, Ján Tomko wrote:
> On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
> > 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>
> > ---
> >  src/interface/interface_backend_netcf.c | 6 +++---
> >  src/interface/interface_backend_udev.c  | 4 ++--
> >  2 files changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
> > index 760540a..3b1d0bd 100644
> > --- a/src/interface/interface_backend_netcf.c
> > +++ b/src/interface/interface_backend_netcf.c
> > @@ -217,7 +217,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
> >      int count;
> >      int want = 0;
> >      int ret = -1;
> > -    int i;
> > +    size_t i;
> >      char **names = NULL;
> >  
> >      /* List all interfaces, in case we might support new filter flags
> 
> In the cleanup section there is
>          for (i = 0; i < count; i++)
> but count can be negative here.
> 
> > @@ -313,7 +313,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
> >      int count = 0;
> >      int want = 0;
> >      int ret = -1;
> > -    int i;
> > +    size_t i;
> >      char **allnames = NULL;
> >  
> >      count = ncf_num_of_interfaces(driver->netcf, status);
> > @@ -483,7 +483,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
> >  {
> >      struct interface_driver *driver = conn->interfacePrivateData;
> >      int count;
> > -    int i;
> > +    size_t i;
> >      struct netcf_if *iface = NULL;
> >      virInterfacePtr *tmp_iface_objs = NULL;
> >      virInterfacePtr iface_obj = NULL;
> 
> Same for these two functions.
> 
> > diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
> > index 6270c9d..0e99ccb 100644
> > --- a/src/interface/interface_backend_udev.c
> > +++ b/src/interface/interface_backend_udev.c
> > @@ -641,7 +641,7 @@ udevGetIfaceDefBond(struct udev *udev,
> >  {
> >      struct dirent **slave_list = NULL;
> >      int slave_count = 0;
> > -    int i;
> > +    size_t i;
> >      const char *tmp_str;
> >      int tmp_int;
> 
> Same for slave_count here.
> 
> >  
> > @@ -872,7 +872,7 @@ udevGetIfaceDefBridge(struct udev *udev,
> >      char *member_path;
> >      const char *tmp_str;
> >      int stp;
> > -    int i;
> > +    size_t i;
> >  
> >      /* Set our type to Bridge  */
> >      ifacedef->type = VIR_INTERFACE_TYPE_BRIDGE;
> > 
> 
> And member_count here.

Squashing in

diff --git a/src/interface/interface_backend_netcf.c b/src/interface/interface_backend_netcf.c
index 7b97b28..b92b0ce 100644
--- a/src/interface/interface_backend_netcf.c
+++ b/src/interface/interface_backend_netcf.c
@@ -289,7 +289,7 @@ static int netcfConnectNumOfInterfacesImpl(virConnectPtr conn,
     ret = want;
 
 cleanup:
-    if (names)
+    if (names && count > 0)
         for (i = 0; i < count; i++)
             VIR_FREE(names[i]);
     VIR_FREE(names);
@@ -386,7 +386,7 @@ static int netcfConnectListInterfacesImpl(virConnectPtr conn,
     ret = want;
 
 cleanup:
-    if (allnames)
+    if (allnames && count > 0)
         for (i = 0; i < count; i++)
             VIR_FREE(allnames[i]);
     VIR_FREE(allnames);
@@ -606,7 +606,7 @@ netcfConnectListAllInterfaces(virConnectPtr conn,
 cleanup:
     ncf_if_free(iface);
 
-    if (names)
+    if (names && count > 0)
         for (i = 0; i < count; i++)
             VIR_FREE(names[i]);
     VIR_FREE(names);
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
index 51ec613..75d5c48 100644
--- a/src/interface/interface_backend_udev.c
+++ b/src/interface/interface_backend_udev.c
@@ -842,7 +842,7 @@ udevGetIfaceDefBond(struct udev *udev,
     return 0;
 
 error:
-    for (i = 0; i < slave_count; i++) {
+    for (i = 0; slave_count != -1 && i < slave_count; i++) {
         VIR_FREE(slave_list[i]);
     }
     VIR_FREE(slave_list);
@@ -949,7 +949,7 @@ udevGetIfaceDefBridge(struct udev *udev,
     return 0;
 
 error:
-    for (i = 0; i < member_count; i++) {
+    for (i = 0; member_count != -1 && i < member_count; i++) {
         VIR_FREE(member_list[i]);
     }
     VIR_FREE(member_list);


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

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