On Tue, Jul 09, 2013 at 09:17:33AM +0200, Ján Tomko wrote:
On 07/08/2013 04:21 PM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange(a)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(a)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
The following will be squashed in
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 68feafa..4013267 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5320,6 +5320,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (ioeventfd) {
+ int val;
+
if (def->bus != VIR_DOMAIN_DISK_BUS_VIRTIO) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("disk ioeventfd mode supported "
@@ -5327,14 +5329,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
goto error;
}
- size_t i;
- if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
+ if ((val = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown disk ioeventfd mode '%s'"),
ioeventfd);
goto error;
}
- def->ioeventfd=i;
+ def->ioeventfd = val;
}
if (event_idx) {
@@ -5390,9 +5391,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
}
if (startupPolicy) {
- size_t i;
+ int val;
- if ((i = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) {
+ if ((val = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown startupPolicy value '%s'"),
startupPolicy);
@@ -5407,7 +5408,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt,
startupPolicy);
goto error;
}
- def->startupPolicy = i;
+ def->startupPolicy = val;
}
def->src = source;
@@ -6471,14 +6472,14 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
def->driver.virtio.txmode = m;
}
if (ioeventfd) {
- size_t i;
- if ((i = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
+ int val;
+ if ((val = virDomainIoEventFdTypeFromString(ioeventfd)) <= 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown interface ioeventfd mode
'%s'"),
ioeventfd);
goto error;
}
- def->driver.virtio.ioeventfd = i;
+ def->driver.virtio.ioeventfd = val;
}
if (event_idx) {
int idx;
@@ -10416,6 +10417,9 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
}
}
+ if (maxController == -1)
+ return 0;
+
for (i = 0; i <= maxController; i++) {
if (virDomainDefMaybeAddController(def, VIR_DOMAIN_CONTROLLER_TYPE_SCSI, i, -1)
< 0)
return -1;
@@ -13391,6 +13395,9 @@ virDomainDefAddDiskControllersForType(virDomainDefPtr def,
maxController = def->disks[i]->info.addr.drive.controller;
}
+ if (maxController == -1)
+ return 0;
+
for (i = 0; i <= maxController; i++) {
if (virDomainDefMaybeAddController(def, controllerType, i, -1) < 0)
return -1;
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 6db9996..fde24be 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -304,22 +304,22 @@ static int
virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList)
{
int old_count = cbList->count;
- size_t i;
- for (i = 0; i < cbList->count; i++) {
- if (cbList->callbacks[i]->deleted) {
- virFreeCallback freecb = cbList->callbacks[i]->freecb;
+ int n;
+ for (n = 0; n < cbList->count; n++) {
+ if (cbList->callbacks[n]->deleted) {
+ virFreeCallback freecb = cbList->callbacks[n]->freecb;
if (freecb)
- (*freecb)(cbList->callbacks[i]->opaque);
- virObjectUnref(cbList->callbacks[i]->conn);
- VIR_FREE(cbList->callbacks[i]);
+ (*freecb)(cbList->callbacks[n]->opaque);
+ virObjectUnref(cbList->callbacks[n]->conn);
+ VIR_FREE(cbList->callbacks[n]);
- if (i < (cbList->count - 1))
- memmove(cbList->callbacks + i,
- cbList->callbacks + i + 1,
+ if (n < (cbList->count - 1))
+ memmove(cbList->callbacks + n,
+ cbList->callbacks + n + 1,
sizeof(*(cbList->callbacks)) *
- (cbList->count - (i + 1)));
+ (cbList->count - (n + 1)));
cbList->count--;
- i--;
+ n--;
}
}
if (cbList->count < old_count &&
diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index 1eb13a8..799405e 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -736,7 +736,8 @@ virNodeDevCapScsiHostParseXML(xmlXPathContextPtr ctxt,
const char *virt_type)
{
xmlNodePtr orignode, *nodes = NULL;
- int ret = -1, n = 0, i;
+ int ret = -1, n = 0;
+ size_t i;
char *type = NULL;
orignode = ctxt->node;
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index 927ab08..7ae4a44 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -44,7 +44,7 @@ static unsigned int virNWFilterVarAccessGetIntIterId(
void
virNWFilterVarValueFree(virNWFilterVarValuePtr val)
{
- unsigned i;
+ size_t i;
if (!val)
return;
@@ -68,7 +68,7 @@ virNWFilterVarValuePtr
virNWFilterVarValueCopy(const virNWFilterVarValuePtr val)
{
virNWFilterVarValuePtr res;
- unsigned i;
+ size_t i;
char *str;
if (VIR_ALLOC(res) < 0)
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 :|