[libvirt] [PATCH 02/32] Convert 'int i' to 'size_t i' in src/conf/ files

Ján Tomko jtomko at redhat.com
Tue Jul 9 07:17:33 UTC 2013


On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at 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 at redhat.com>
> ---
>  src/conf/capabilities.c            |  32 ++--
>  src/conf/cpu_conf.c                |  18 +--
>  src/conf/domain_audit.c            |   4 +-
>  src/conf/domain_conf.c             | 266 ++++++++++++++++---------------
>  src/conf/domain_conf.h             |  12 +-
>  src/conf/domain_event.c            |  24 +--
>  src/conf/domain_nwfilter.c         |   2 +-
>  src/conf/interface_conf.c          |  73 +++++----
>  src/conf/netdev_vlan_conf.c        |  19 +--
>  src/conf/network_conf.c            | 319 +++++++++++++++++++------------------
>  src/conf/node_device_conf.c        |  27 ++--
>  src/conf/nwfilter_conf.c           |  43 ++---
>  src/conf/nwfilter_params.c         |  26 +--
>  src/conf/snapshot_conf.c           |  21 +--
>  src/conf/storage_conf.c            |  42 ++---
>  src/conf/storage_encryption_conf.c |   3 +-
>  16 files changed, 482 insertions(+), 449 deletions(-)
> 

> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 402e6e9..b9713e6 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c
> @@ -5362,7 +5364,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
>              goto error;
>          }
>  
> -        int i;
> +        size_t i;
>          if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
>              virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                             _("unknown disk ioeventfd mode '%s'"),
> @@ -5425,7 +5427,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
>      }
>  
>      if (startupPolicy) {
> -        int i;
> +        size_t i;
>  
>          if ((i = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) {
>              virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> @@ -6518,7 +6520,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
>              def->driver.virtio.txmode = m;
>          }
>          if (ioeventfd) {
> -            int i;
> +            size_t i;
>              if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
>                  virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
>                                 _("unknown interface ioeventfd mode '%s'"),

These three need to be signed.

>  virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
>  {
>      /* Look for any hostdev scsi dev */
> -    int i;
> +    size_t i;
>      int maxController = -1;

If no SCSI hostdevs are found, the for condition is i <= -1, and a LOT of SCSI
controllers is added.

>      virDomainHostdevDefPtr hostdev;
>  
> @@ -13489,7 +13495,7 @@ virDomainDefAddDiskControllersForType(virDomainDefPtr def,
>                                        int controllerType,
>                                        int diskBus)
>  {
> -    int i;
> +    size_t i;
>      int maxController = -1;
>  
>      for (i = 0; i < def->ndisks; i++) {

Same here.

>  virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList)
>  {
>      int old_count = cbList->count;
> -    int i;
> +    size_t i;
>      for (i = 0; i < cbList->count; i++) {
>          if (cbList->callbacks[i]->deleted) {
>              virFreeCallback freecb = cbList->callbacks[i]->freecb;

If this condition is true when i = 0, i gets decremented then incremented.

ACK

Jan




More information about the libvir-list mailing list