On Wed, Jul 10, 2013 at 10:15:27AM +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/qemu/qemu_agent.c | 9 ++-- > > src/qemu/qemu_capabilities.c | 7 +-- > > src/qemu/qemu_cgroup.c | 12 ++--- > > src/qemu/qemu_command.c | 104 +++++++++++++++++++------------------ > > src/qemu/qemu_conf.c | 2 +- > > src/qemu/qemu_domain.c | 34 ++++++------ > > src/qemu/qemu_driver.c | 120 +++++++++++++++++++++++-------------------- > > src/qemu/qemu_hostdev.c | 26 +++++----- > > src/qemu/qemu_hotplug.c | 54 ++++++++++--------- > > src/qemu/qemu_migration.c | 25 ++++----- > > src/qemu/qemu_monitor.c | 13 ++--- > > src/qemu/qemu_monitor_json.c | 31 ++++++----- > > src/qemu/qemu_monitor_text.c | 6 +-- > > src/qemu/qemu_process.c | 48 ++++++++--------- > > 14 files changed, 259 insertions(+), 232 deletions(-) > > > > > @@ -2135,13 +2137,13 @@ qemuDomainCleanupRun(virQEMUDriverPtr driver, > > virDomainObjPtr vm) > > { > > qemuDomainObjPrivatePtr priv = vm->privateData; > > - int i; > > + size_t i; > > > > VIR_DEBUG("driver=%p, vm=%s", driver, vm->def->name); > > > > /* run cleanup callbacks in reverse order */ > > - for (i = priv->ncleanupCallbacks - 1; i >= 0; i--) { > > - if (priv->cleanupCallbacks[i]) > > + for (i = 0; i < priv->ncleanupCallbacks; i++) { > > + if (priv->cleanupCallbacks[priv->ncleanupCallbacks - (i + 1)]) > > priv->cleanupCallbacks[i](driver, vm); > > } > > > > This changes the order in which cleanup callbacks are run. No it doesn't actually. Lets say ncleanupCallbacks = 5 Old code 1st iteration: i == 4, callback 4 is run New code, 1st iteration i == 0, callback (ncleanupCallbacks - (i + 1)) == (5 - (0 + 1)) == 4 is run > > > > @@ -12227,9 +12232,10 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, > > ret = qemuMonitorTransaction(priv->mon, actions); > > virJSONValueFree(actions); > > if (ret < 0) { > > + int idx = i; > > /* Transaction failed; undo the changes to vm. */ > > bool need_unlink = !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT); > > - while (--i >= 0) { > > + while (--idx >= 0) { > > virDomainDiskDefPtr persistDisk = NULL; > > > > if (snap->def->disks[i].snapshot == > > How about while (i-- > 0)? > > > @@ -4286,7 +4287,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver, > > > > static int > > qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) { > > - int i; > > + size_t i; > > int last_good_net = -1; > > virDomainNetDefPtr net; > > > > Jumping to err_exit with last_good_net = -1 leads to i < -1 comparison. Squashing in diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0756976..798a9b4 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7505,12 +7505,14 @@ qemuBuildCommandLine(virConnectPtr conn, for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; - int vlan = i; + int vlan; /* VLANs are not used with -netdev, so don't record them */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV) && virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) vlan = -1; + else + vlan = i; if (qemuBuildInterfaceCommandLine(cmd, driver, conn, def, net, qemuCaps, vlan, bootNet, vmop) < 0) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 37be3a6..687c873 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8970,7 +8970,7 @@ qemuDomainBlockResize(virDomainPtr dom, virQEMUDriverPtr driver = dom->conn->privateData; virDomainObjPtr vm; qemuDomainObjPrivatePtr priv; - int ret = -1, i; + int ret = -1, idx; char *device = NULL; virDomainDiskDefPtr disk = NULL; @@ -9010,12 +9010,12 @@ qemuDomainBlockResize(virDomainPtr dom, goto endjob; } - if ((i = virDomainDiskIndexByName(vm->def, path, false)) < 0) { + if ((idx = virDomainDiskIndexByName(vm->def, path, false)) < 0) { virReportError(VIR_ERR_INVALID_ARG, _("invalid path: %s"), path); goto endjob; } - disk = vm->def->disks[i]; + disk = vm->def->disks[idx]; if (virAsprintf(&device, "%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) @@ -12176,10 +12176,9 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, ret = qemuMonitorTransaction(priv->mon, actions); virJSONValueFree(actions); if (ret < 0) { - int idx = i; /* Transaction failed; undo the changes to vm. */ bool need_unlink = !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT); - while (--idx >= 0) { + while (i-- > 0) { virDomainDiskDefPtr persistDisk = NULL; if (snap->def->disks[i].snapshot == @@ -12197,7 +12196,6 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver, snap->def->dom->disks[i], vm->def->disks[i], persistDisk, - need_unlink); } } diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 3ffc6ac..adcd638 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4277,7 +4277,7 @@ qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) { return 0; err_exit: - for (i = 0; i < last_good_net; i++) { + for (i = 0; last_good_net != -1 && i < last_good_net; i++) { net = def->nets[i]; if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) { ignore_value(virNetDevVPortProfileDisassociate(net->ifname, 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