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/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(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 9914521..a878c02 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -137,7 +137,7 @@ VIR_ONCE_GLOBAL_INIT(qemuAgent)
static char *
qemuAgentEscapeNonPrintable(const char *text)
{
- int i;
+ size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
for (i = 0; text[i] != '\0'; i++) {
if (text[i] == '\\')
@@ -169,7 +169,8 @@ qemuAgentOpenUnix(const char *monitor, pid_t cpid, bool *inProgress)
struct sockaddr_un addr;
int monfd;
int timeout = 3; /* In seconds */
- int ret, i = 0;
+ int ret;
+ size_t i = 0;
*inProgress = false;
@@ -359,7 +360,7 @@ static int qemuAgentIOProcessData(qemuAgentPtr mon,
qemuAgentMessagePtr msg)
{
int used = 0;
- int i = 0;
+ size_t i = 0;
#if DEBUG_IO
# if DEBUG_RAW_IO
char *str1 = qemuAgentEscapeNonPrintable(data);
@@ -1469,7 +1470,7 @@ qemuAgentGetVCPUs(qemuAgentPtr mon,
qemuAgentCPUInfoPtr *info)
{
int ret = -1;
- int i;
+ size_t i;
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr data = NULL;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 969b001..169f477 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -670,7 +670,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
virArch guestarch)
{
virCapsGuestPtr guest;
- int i;
+ size_t i;
bool haskvm = false;
bool haskqemu = false;
char *kvmbin = NULL;
@@ -878,7 +878,7 @@ error:
virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
{
virCapsPtr caps;
- int i;
+ size_t i;
virArch hostarch = virArchFromHost();
if ((caps = virCapabilitiesNew(hostarch,
@@ -2183,7 +2183,8 @@ static int
virQEMUCapsProbeQMPTPM(virQEMUCapsPtr qemuCaps,
qemuMonitorPtr mon)
{
- int nentries, i;
+ int nentries;
+ size_t i;
char **entries = NULL;
if ((nentries = qemuMonitorGetTPMModels(mon, &entries)) < 0)
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 22bf78e..b92a1f5 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -413,7 +413,7 @@ qemuSetupBlkioCgroup(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
int rc = -1;
- int i;
+ size_t i;
if (!virCgroupHasController(priv->cgroup,
VIR_CGROUP_CONTROLLER_BLKIO)) {
@@ -516,7 +516,7 @@ qemuSetupDevicesCgroup(virQEMUDriverPtr driver,
const char *const *deviceACL = NULL;
int rc = -1;
int ret = -1;
- int i;
+ size_t i;
if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_DEVICES))
return 0;
@@ -884,7 +884,7 @@ int qemuSetupCgroupVcpuPin(virCgroupPtr cgroup,
int nvcpupin,
int vcpuid)
{
- int i;
+ size_t i;
for (i = 0; i < nvcpupin; i++) {
if (vcpuid == vcpupin[i]->vcpuid) {
@@ -928,7 +928,7 @@ int qemuSetupCgroupForVcpu(virDomainObjPtr vm)
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
int rc;
- unsigned int i, j;
+ size_t i, j;
unsigned long long period = vm->def->cputune.period;
long long quota = vm->def->cputune.quota;
@@ -959,7 +959,7 @@ int qemuSetupCgroupForVcpu(virDomainObjPtr vm)
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to create vcpu cgroup for %s(vcpu:"
- " %d)"),
+ " %zu)"),
vm->def->name, i);
goto cleanup;
}
@@ -968,7 +968,7 @@ int qemuSetupCgroupForVcpu(virDomainObjPtr vm)
rc = virCgroupAddTask(cgroup_vcpu, priv->vcpupids[i]);
if (rc < 0) {
virReportSystemError(-rc,
- _("unable to add vcpu %d task %d to cgroup"),
+ _("unable to add vcpu %zu task %d to
cgroup"),
i, priv->vcpupids[i]);
goto cleanup;
}
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 46db28a..a5549df 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -402,7 +402,7 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
cleanup:
if (ret < 0) {
- int i;
+ size_t i;
for (i = 0; i < *tapfdSize; i++)
VIR_FORCE_CLOSE(tapfd[i]);
if (template_ifname)
@@ -437,7 +437,7 @@ qemuOpenVhostNet(virDomainDefPtr def,
int *vhostfd,
int *vhostfdSize)
{
- int i;
+ size_t i;
/* If the config says explicitly to not use vhost, return now */
if (net->driver.virtio.name == VIR_DOMAIN_NET_BACKEND_TYPE_QEMU) {
@@ -487,7 +487,7 @@ qemuOpenVhostNet(virDomainDefPtr def,
"but is unavailable"));
goto error;
}
- VIR_WARN("Unable to open vhost-net. Opened so far %d, requested
%d",
+ VIR_WARN("Unable to open vhost-net. Opened so far %zu, requested
%d",
i, *vhostfdSize);
*vhostfdSize = i;
break;
@@ -507,10 +507,10 @@ int
qemuNetworkPrepareDevices(virDomainDefPtr def)
{
int ret = -1;
- int ii;
+ size_t i;
- for (ii = 0; ii < def->nnets; ii++) {
- virDomainNetDefPtr net = def->nets[ii];
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
int actualType;
/* If appropriate, grab a physical device from the configured
@@ -787,7 +787,7 @@ int
qemuAssignDeviceNetAlias(virDomainDefPtr def, virDomainNetDefPtr net, int idx)
{
if (idx == -1) {
- int i;
+ size_t i;
idx = 0;
for (i = 0; i < def->nnets; i++) {
int thisidx;
@@ -819,7 +819,7 @@ int
qemuAssignDeviceHostdevAlias(virDomainDefPtr def, virDomainHostdevDefPtr hostdev, int
idx)
{
if (idx == -1) {
- int i;
+ size_t i;
idx = 0;
for (i = 0; i < def->nhostdevs; i++) {
int thisidx;
@@ -855,7 +855,7 @@ int
qemuAssignDeviceRedirdevAlias(virDomainDefPtr def, virDomainRedirdevDefPtr redirdev, int
idx)
{
if (idx == -1) {
- int i;
+ size_t i;
idx = 0;
for (i = 0; i < def->nredirdevs; i++) {
int thisidx;
@@ -896,7 +896,7 @@ qemuAssignDeviceControllerAlias(virDomainControllerDefPtr controller)
int
qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
{
- int i;
+ size_t i;
for (i = 0; i < def->ndisks; i++) {
if (qemuAssignDeviceDiskAlias(def, def->disks[i], qemuCaps) < 0)
@@ -919,11 +919,11 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr
qemuCaps)
return 0;
for (i = 0; i < def->nfss; i++) {
- if (virAsprintf(&def->fss[i]->info.alias, "fs%d", i) < 0)
+ if (virAsprintf(&def->fss[i]->info.alias, "fs%zu", i) <
0)
goto no_memory;
}
for (i = 0; i < def->nsounds; i++) {
- if (virAsprintf(&def->sounds[i]->info.alias, "sound%d", i)
< 0)
+ if (virAsprintf(&def->sounds[i]->info.alias, "sound%zu", i)
< 0)
goto no_memory;
}
for (i = 0; i < def->nhostdevs; i++) {
@@ -935,7 +935,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps)
return -1;
}
for (i = 0; i < def->nvideos; i++) {
- if (virAsprintf(&def->videos[i]->info.alias, "video%d", i)
< 0)
+ if (virAsprintf(&def->videos[i]->info.alias, "video%zu", i)
< 0)
goto no_memory;
}
for (i = 0; i < def->ncontrollers; i++) {
@@ -943,31 +943,31 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr
qemuCaps)
return -1;
}
for (i = 0; i < def->ninputs; i++) {
- if (virAsprintf(&def->inputs[i]->info.alias, "input%d", i)
< 0)
+ if (virAsprintf(&def->inputs[i]->info.alias, "input%zu", i)
< 0)
goto no_memory;
}
for (i = 0; i < def->nparallels; i++) {
- if (virAsprintf(&def->parallels[i]->info.alias, "parallel%d",
i) < 0)
+ if (virAsprintf(&def->parallels[i]->info.alias,
"parallel%zu", i) < 0)
goto no_memory;
}
for (i = 0; i < def->nserials; i++) {
- if (virAsprintf(&def->serials[i]->info.alias, "serial%d", i)
< 0)
+ if (virAsprintf(&def->serials[i]->info.alias, "serial%zu", i)
< 0)
goto no_memory;
}
for (i = 0; i < def->nchannels; i++) {
- if (virAsprintf(&def->channels[i]->info.alias, "channel%d",
i) < 0)
+ if (virAsprintf(&def->channels[i]->info.alias, "channel%zu",
i) < 0)
goto no_memory;
}
for (i = 0; i < def->nconsoles; i++) {
- if (virAsprintf(&def->consoles[i]->info.alias, "console%d",
i) < 0)
+ if (virAsprintf(&def->consoles[i]->info.alias, "console%zu",
i) < 0)
goto no_memory;
}
for (i = 0; i < def->nhubs; i++) {
- if (virAsprintf(&def->hubs[i]->info.alias, "hub%d", i) <
0)
+ if (virAsprintf(&def->hubs[i]->info.alias, "hub%zu", i) <
0)
goto no_memory;
}
for (i = 0; i < def->nsmartcards; i++) {
- if (virAsprintf(&def->smartcards[i]->info.alias,
"smartcard%d", i) < 0)
+ if (virAsprintf(&def->smartcards[i]->info.alias,
"smartcard%zu", i) < 0)
goto no_memory;
}
if (def->watchdog) {
@@ -1097,7 +1097,7 @@ qemuDomainPrimeS390VirtioDevices(virDomainDefPtr def,
disks, networks, consoles, controllers, memballoon and rng in this
order
*/
- int i;
+ size_t i;
for (i = 0; i < def->ndisks; i++) {
if (def->disks[i]->bus == VIR_DOMAIN_DISK_BUS_VIRTIO &&
@@ -1320,7 +1320,8 @@ qemuAssignSpaprVIOAddress(virDomainDefPtr def,
virDomainDeviceInfoPtr info,
int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
int model;
/* Default values match QEMU. See spapr_(llan|vscsi|vty).c */
@@ -1450,7 +1451,8 @@ static int
qemuDomainPCIAddressSetGrow(qemuDomainPCIAddressSetPtr addrs,
virDevicePCIAddressPtr addr)
{
- int add, i;
+ int add;
+ size_t i;
add = addr->bus - addrs->nbuses + 1;
i = addrs->nbuses;
@@ -1580,7 +1582,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
int max_idx = -1;
int nbuses = 0;
- int i;
+ size_t i;
int rv;
for (i = 0; i < def->ncontrollers; i++) {
@@ -1674,7 +1676,7 @@ qemuDomainPCIAddressSetPtr
qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
bool dryRun)
{
qemuDomainPCIAddressSetPtr addrs;
- int i;
+ size_t i;
if (VIR_ALLOC(addrs) < 0)
goto no_memory;
@@ -2411,7 +2413,8 @@ qemuBuildRBDString(virConnectPtr conn,
virDomainDiskDefPtr disk,
virBufferPtr opt)
{
- int i, ret = 0;
+ size_t i;
+ int ret = 0;
virSecretPtr sec = NULL;
char *secret = NULL;
size_t secret_size;
@@ -4139,7 +4142,7 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
virBuffer buf = VIR_BUFFER_INITIALIZER;
enum virDomainNetType netType = virDomainNetGetActualType(net);
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- int i;
+ size_t i;
if (net->script && netType != VIR_DOMAIN_NET_TYPE_ETHERNET) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
@@ -5539,7 +5542,7 @@ qemuBuildClockArgStr(virDomainClockDefPtr def)
}
/* Look for an 'rtc' timer element, and add in appropriate clock= and
driftfix= */
- int i;
+ size_t i;
for (i = 0; i < def->ntimers; i++) {
if (def->timers[i]->name == VIR_DOMAIN_TIMER_NAME_RTC) {
switch (def->timers[i]->track) {
@@ -5613,7 +5616,7 @@ qemuBuildCpuArgStr(const virQEMUDriverPtr driver,
char *compare_msg = NULL;
int ret = -1;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- int i;
+ size_t i;
virCapsPtr caps = NULL;
*hasHwVirt = false;
@@ -6022,7 +6025,7 @@ qemuBuildSmpArgStr(const virDomainDefPtr def,
static int
qemuBuildNumaArgStr(const virDomainDefPtr def, virCommandPtr cmd)
{
- int i;
+ size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *cpumask = NULL;
int ret = -1;
@@ -6230,7 +6233,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg,
int defaultMode = graphics->data.spice.defaultMode;
int port = graphics->data.spice.port;
int tlsPort = graphics->data.spice.tlsPort;
- int i;
+ size_t i;
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -6497,7 +6500,7 @@ qemuBuildInterfaceCommandLine(virCommandPtr cmd,
char **tapfdName = NULL;
char **vhostfdName = NULL;
int actualType = virDomainNetGetActualType(net);
- int i;
+ size_t i;
if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
/* NET_TYPE_HOSTDEV devices are really hostdev devices, so
@@ -6668,7 +6671,7 @@ qemuBuildCommandLine(virConnectPtr conn,
qemuBuildCommandLineCallbacksPtr callbacks)
{
virErrorPtr originalError = NULL;
- int i, j;
+ size_t i, j;
const char *emulator;
char uuid[VIR_UUID_STRING_BUFLEN];
char *cpu;
@@ -7649,7 +7652,7 @@ qemuBuildCommandLine(virConnectPtr conn,
smartcard->data.cert.file[j]);
goto error;
}
- virBufferAsprintf(&opt, ",cert%d=%s", j + 1,
+ virBufferAsprintf(&opt, ",cert%zu=%s", j + 1,
smartcard->data.cert.file[j]);
}
if (smartcard->data.cert.database) {
@@ -8135,18 +8138,17 @@ qemuBuildCommandLine(virConnectPtr conn,
if (sound->model == VIR_DOMAIN_SOUND_MODEL_ICH6) {
char *codecstr = NULL;
- int ii;
- for (ii = 0; ii < sound->ncodecs; ii++) {
+ for (j = 0; j < sound->ncodecs; j++) {
virCommandAddArg(cmd, "-device");
- if (!(codecstr = qemuBuildSoundCodecStr(sound,
sound->codecs[ii], qemuCaps))) {
+ if (!(codecstr = qemuBuildSoundCodecStr(sound,
sound->codecs[j], qemuCaps))) {
goto error;
}
virCommandAddArg(cmd, codecstr);
VIR_FREE(codecstr);
}
- if (ii == 0) {
+ if (j == 0) {
virDomainSoundCodecDef codec = {
VIR_DOMAIN_SOUND_CODEC_TYPE_DUPLEX,
0
@@ -8655,7 +8657,7 @@ static int qemuStringToArgvEnv(const char *args,
int argcount = 0;
int argalloc = 0;
int envend;
- int i;
+ size_t i;
const char *curr = args;
const char *start;
const char **progenv = NULL;
@@ -8758,7 +8760,7 @@ error:
static const char *qemuFindEnv(const char **progenv,
const char *name)
{
- int i;
+ size_t i;
int len = strlen(name);
for (i = 0; progenv && progenv[i]; i++) {
@@ -8788,7 +8790,7 @@ qemuParseKeywords(const char *str,
char **values = NULL;
const char *start = str;
const char *end;
- int i;
+ size_t i;
*retkeywords = NULL;
*retvalues = NULL;
@@ -8893,7 +8895,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
char **keywords;
char **values;
int nkeywords;
- int i;
+ size_t i;
int idx = -1;
int busid = -1;
int unitid = -1;
@@ -9198,7 +9200,7 @@ qemuFindNICForVLAN(int nnics,
const char **nics,
int wantvlan)
{
- int i;
+ size_t i;
for (i = 0; i < nnics; i++) {
int gotvlan;
const char *tmp = strstr(nics[i], "vlan=");
@@ -9246,7 +9248,7 @@ qemuParseCommandLineNet(virDomainXMLOptionPtr xmlopt,
int wantvlan = 0;
const char *tmp;
bool genmac = true;
- int i;
+ size_t i;
tmp = strchr(val, ',');
@@ -9635,7 +9637,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
char **hv_tokens = NULL;
char *model = NULL;
int ret = -1;
- int i;
+ size_t i;
if (!(tokens = virStringSplit(val, ",", 0)))
goto cleanup;
@@ -9672,7 +9674,7 @@ qemuParseCommandLineCPU(virDomainDefPtr dom,
if (STREQ(feature, "kvmclock")) {
bool present = (policy == VIR_CPU_FEATURE_REQUIRE);
- int j;
+ size_t j;
for (j = 0; j < dom->clock.ntimers; j++) {
if (dom->clock.timers[j]->name ==
VIR_DOMAIN_TIMER_NAME_KVMCLOCK)
@@ -9821,7 +9823,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom,
unsigned int cores = 0;
unsigned int threads = 0;
unsigned int maxcpus = 0;
- int i;
+ size_t i;
int nkws;
char **kws;
char **vals;
@@ -9923,7 +9925,7 @@ virDomainDefPtr qemuParseCommandLine(virCapsPtr qemuCaps,
bool *monJSON)
{
virDomainDefPtr def;
- int i;
+ size_t i;
bool nographics = false;
bool fullscreen = false;
char *path;
@@ -10884,7 +10886,7 @@ virDomainDefPtr qemuParseCommandLineString(virCapsPtr qemuCaps,
const char **progenv = NULL;
const char **progargv = NULL;
virDomainDefPtr def = NULL;
- int i;
+ size_t i;
if (qemuStringToArgvEnv(args, &progenv, &progargv) < 0)
goto cleanup;
@@ -10916,7 +10918,7 @@ static int qemuParseProcFileStrings(int pid_value,
char *tmp;
size_t nstr = 0;
char **str = NULL;
- int i;
+ size_t i;
if (virAsprintf(&path, "/proc/%d/%s", pid_value, name) < 0) {
virReportOOMError();
@@ -10974,7 +10976,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr qemuCaps,
const char **progenv = NULL;
char *exepath = NULL;
char *emulator;
- int i;
+ size_t i;
/* The parser requires /proc/pid, which only exists on platforms
* like Linux where pid_t fits in int. */
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 094f9f7..1429d8d 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -310,7 +310,7 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
virConfPtr conf = NULL;
virConfValuePtr p;
int ret = -1;
- int i;
+ size_t i;
/* Just check the file is readable before opening it, otherwise
* libvirt emits an error.
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 28b8ee4..e8b366f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -289,7 +289,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
if (priv->nvcpupids) {
- int i;
+ size_t i;
virBufferAddLit(buf, " <vcpus>\n");
for (i = 0; i < priv->nvcpupids; i++) {
virBufferAsprintf(buf, " <vcpu pid='%d'/>\n",
priv->vcpupids[i]);
@@ -298,7 +298,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data)
}
if (priv->qemuCaps) {
- int i;
+ size_t i;
virBufferAddLit(buf, " <qemuCaps>\n");
for (i = 0; i < QEMU_CAPS_LAST; i++) {
if (virQEMUCapsGet(priv->qemuCaps, i)) {
@@ -341,7 +341,8 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt, void *data)
qemuDomainObjPrivatePtr priv = data;
char *monitorpath;
char *tmp;
- int n, i;
+ int n;
+ size_t i;
xmlNodePtr *nodes = NULL;
virQEMUCapsPtr qemuCaps = NULL;
@@ -498,7 +499,7 @@ static void
qemuDomainDefNamespaceFree(void *nsdata)
{
qemuDomainCmdlineDefPtr cmd = nsdata;
- unsigned int i;
+ size_t i;
if (!cmd)
return;
@@ -524,7 +525,8 @@ qemuDomainDefNamespaceParse(xmlDocPtr xml ATTRIBUTE_UNUSED,
qemuDomainCmdlineDefPtr cmd = NULL;
bool uses_qemu_ns = false;
xmlNodePtr *nodes = NULL;
- int n, i;
+ int n;
+ size_t i;
if (xmlXPathRegisterNs(ctxt, BAD_CAST "qemu", BAD_CAST QEMU_NAMESPACE_HREF)
< 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -626,7 +628,7 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
void *nsdata)
{
qemuDomainCmdlineDefPtr cmd = nsdata;
- unsigned int i;
+ size_t i;
if (!cmd->num_args && !cmd->num_env)
return 0;
@@ -1338,7 +1340,7 @@ qemuDomainDefFormatBuf(virQEMUDriverPtr driver,
}
if ((flags & VIR_DOMAIN_XML_MIGRATABLE)) {
- int i;
+ size_t i;
int toremove = 0;
virDomainControllerDefPtr usb = NULL, pci = NULL;
@@ -1507,7 +1509,7 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
virDomainObjPtr obj,
int logFD)
{
- int i;
+ size_t i;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
if (cfg->privileged &&
@@ -1776,7 +1778,7 @@ qemuDomainSnapshotForEachQcow2Raw(virQEMUDriverPtr driver,
int ndisks)
{
const char *qemuimgarg[] = { NULL, "snapshot", NULL, NULL, NULL, NULL };
- int i;
+ size_t i;
bool skipped = false;
qemuimgarg[0] = qemuFindQemuImgBinary(driver);
@@ -2012,7 +2014,7 @@ qemuDomainCheckDiskPresence(virQEMUDriverPtr driver,
bool cold_boot)
{
int ret = -1;
- int i;
+ size_t i;
virDomainDiskDefPtr disk;
char uuid[VIR_UUID_STRING_BUFLEN];
virDomainEventPtr event = NULL;
@@ -2087,7 +2089,7 @@ qemuDomainCleanupAdd(virDomainObjPtr vm,
qemuDomainCleanupCallback cb)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int i;
+ size_t i;
VIR_DEBUG("vm=%s, cb=%p", vm->def->name, cb);
@@ -2112,7 +2114,7 @@ qemuDomainCleanupRemove(virDomainObjPtr vm,
qemuDomainCleanupCallback cb)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int i;
+ size_t i;
VIR_DEBUG("vm=%s, cb=%p", vm->def->name, cb);
@@ -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);
}
@@ -2187,7 +2189,7 @@ unsigned long long
qemuDomainMemoryLimit(virDomainDefPtr def)
{
unsigned long long mem;
- int i;
+ size_t i;
if (def->mem.hard_limit) {
mem = def->mem.hard_limit;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1b9ba41..44f880d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -512,7 +512,7 @@ static int
qemuDomainNetsRestart(virDomainObjPtr vm,
void *data ATTRIBUTE_UNUSED)
{
- int i;
+ size_t i;
virDomainDefPtr def = vm->def;
virObjectLock(vm);
@@ -2338,7 +2338,7 @@ static int qemuDomainSendKey(virDomainPtr domain,
/* translate the keycode to RFB for qemu driver */
if (codeset != VIR_KEYCODE_SET_RFB) {
- int i;
+ size_t i;
int keycode;
for (i = 0; i < nkeycodes; i++) {
@@ -3814,7 +3814,8 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
unsigned int nvcpus)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int i, rc = 1;
+ size_t i;
+ int rc = 1;
int ret = -1;
int oldvcpus = vm->def->vcpus;
int vcpus = oldvcpus;
@@ -3892,7 +3893,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to create vcpu cgroup for
%s(vcpu:"
- " %d)"),
+ " %zu)"),
vm->def->name, i);
goto cleanup;
}
@@ -3901,7 +3902,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
rv = virCgroupAddTask(cgroup_vcpu, cpupids[i]);
if (rv < 0) {
virReportSystemError(-rv,
- _("unable to add vcpu %d task %d to
cgroup"),
+ _("unable to add vcpu %zu task %d to
cgroup"),
i, cpupids[i]);
virCgroupRemove(cgroup_vcpu);
goto cleanup;
@@ -3937,7 +3938,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
vm->def->cputune.nvcpupin, i) <
0) {
virReportError(VIR_ERR_OPERATION_INVALID,
_("failed to set cpuset.cpus in cgroup"
- " for vcpu %d"), i);
+ " for vcpu %zu"), i);
ret = -1;
goto cleanup;
}
@@ -3945,7 +3946,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
if (virProcessSetAffinity(cpupids[i],
vcpupin->cpumask) < 0) {
virReportError(VIR_ERR_SYSTEM_ERROR,
- _("failed to set cpu affinity for vcpu
%d"),
+ _("failed to set cpu affinity for vcpu
%zu"),
i);
ret = -1;
goto cleanup;
@@ -3966,7 +3967,7 @@ static int qemuDomainHotplugVcpus(virQEMUDriverPtr driver,
if (rv < 0) {
virReportSystemError(-rv,
_("Unable to access vcpu cgroup for
%s(vcpu:"
- " %d)"),
+ " %zu)"),
vm->def->name, i);
goto cleanup;
}
@@ -4009,7 +4010,7 @@ qemuDomainPrepareAgentVCPUs(unsigned int nvcpus,
qemuAgentCPUInfoPtr cpuinfo,
int ncpuinfo)
{
- int i;
+ size_t i;
int nonline = 0;
int nofflinable = 0;
@@ -4727,7 +4728,8 @@ qemuDomainGetVcpus(virDomainPtr dom,
unsigned char *cpumaps,
int maplen) {
virDomainObjPtr vm;
- int i, v, maxcpu, hostcpus;
+ size_t i;
+ int v, maxcpu, hostcpus;
int ret = -1;
qemuDomainObjPrivatePtr priv;
@@ -4824,7 +4826,7 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
virCapsPtr caps = NULL;
qemuAgentCPUInfoPtr cpuinfo = NULL;
int ncpuinfo = -1;
- int i;
+ size_t i;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG |
@@ -4968,7 +4970,8 @@ static int qemuDomainGetSecurityLabelList(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
if (!(vm = qemuDomObjFromDomain(dom)))
return -1;
@@ -5698,7 +5701,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
bool monitor_json = false;
virCommandPtr cmd = NULL;
char *ret = NULL;
- int i;
+ size_t i;
virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
@@ -5814,7 +5817,7 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
!graphics->data.vnc.socket && graphics->data.vnc.autoport) {
graphics->data.vnc.port = 5900;
} else if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) {
- int j;
+ size_t j;
bool needTLSPort = false;
bool needPort = false;
int defaultMode = graphics->data.spice.defaultMode;
@@ -7488,7 +7491,7 @@ qemuDomainParseDeviceWeightStr(char *deviceWeightStr,
char *temp;
int ndevices = 0;
int nsep = 0;
- int i;
+ size_t i;
virBlkioDeviceWeightPtr result = NULL;
*dw = NULL;
@@ -7571,7 +7574,7 @@ qemuDomainMergeDeviceWeights(virBlkioDeviceWeightPtr *dest_array,
virBlkioDeviceWeightPtr src_array,
size_t src_size)
{
- int i, j;
+ size_t i, j;
virBlkioDeviceWeightPtr dest, src;
for (i = 0; i < src_size; i++) {
@@ -7610,7 +7613,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
int ret = -1;
@@ -7675,7 +7678,7 @@ qemuDomainSetBlkioParameters(virDomainPtr dom,
} else if (STREQ(param->field, VIR_DOMAIN_BLKIO_DEVICE_WEIGHT)) {
size_t ndevices;
virBlkioDeviceWeightPtr devices = NULL;
- int j;
+ size_t j;
if (qemuDomainParseDeviceWeightStr(params[i].value.s,
&devices,
@@ -7761,7 +7764,7 @@ qemuDomainGetBlkioParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i, j;
+ size_t i, j;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
unsigned int val;
@@ -8075,7 +8078,7 @@ qemuDomainGetMemoryParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
int ret = -1;
@@ -8229,7 +8232,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainDefPtr persistentDef = NULL;
virDomainObjPtr vm = NULL;
int ret = -1;
@@ -8375,7 +8378,7 @@ qemuDomainGetNumaParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
char *nodeset = NULL;
@@ -8479,7 +8482,7 @@ static int
qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
unsigned long long period, long long quota)
{
- int i;
+ size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr cgroup_vcpu = NULL;
int rc;
@@ -8497,7 +8500,7 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup,
if (rc < 0) {
virReportSystemError(-rc,
_("Unable to find vcpu cgroup for
%s(vcpu:"
- " %d)"),
+ " %zu)"),
vm->def->name, i);
goto cleanup;
}
@@ -8566,7 +8569,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr vmdef = NULL;
unsigned long long value_ul;
@@ -9088,7 +9091,8 @@ qemuDomainBlockStats(virDomainPtr dom,
struct _virDomainBlockStats *stats)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i, ret = -1;
+ int idx;
+ int ret = -1;
virDomainObjPtr vm;
virDomainDiskDefPtr disk = NULL;
qemuDomainObjPrivatePtr priv;
@@ -9105,12 +9109,12 @@ qemuDomainBlockStats(virDomainPtr dom,
goto cleanup;
}
- 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 cleanup;
}
- disk = vm->def->disks[i];
+ disk = vm->def->disks[idx];
if (!disk->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -9160,7 +9164,8 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i, tmp, ret = -1;
+ int idx;
+ int tmp, ret = -1;
virDomainObjPtr vm;
virDomainDiskDefPtr disk = NULL;
qemuDomainObjPrivatePtr priv;
@@ -9189,12 +9194,12 @@ qemuDomainBlockStatsFlags(virDomainPtr dom,
}
if (*nparams != 0) {
- 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 (!disk->info.alias) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -9326,7 +9331,7 @@ qemuDomainInterfaceStats(virDomainPtr dom,
struct _virDomainInterfaceStats *stats)
{
virDomainObjPtr vm;
- int i;
+ size_t i;
int ret = -1;
if (!(vm = qemuDomObjFromDomain(dom)))
@@ -9381,7 +9386,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr persistentDef = NULL;
int ret = -1;
@@ -9558,7 +9563,7 @@ qemuDomainGetInterfaceParameters(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- int i;
+ size_t i;
virDomainObjPtr vm = NULL;
virDomainDefPtr def = NULL;
virDomainDefPtr persistentDef = NULL;
@@ -9888,7 +9893,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
virStorageFileMetadata *meta = NULL;
virDomainDiskDefPtr disk = NULL;
struct stat sb;
- int i;
+ int idx;
int format;
virQEMUDriverConfigPtr cfg = NULL;
@@ -9909,12 +9914,12 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
}
/* Check the path belongs to this domain. */
- if ((i = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
+ if ((idx = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("invalid path %s not assigned to domain"), path);
goto cleanup;
}
- disk = vm->def->disks[i];
+ disk = vm->def->disks[idx];
if (!disk->src) {
virReportError(VIR_ERR_INVALID_ARG,
_("disk %s does not currently have a source assigned"),
@@ -11685,7 +11690,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
virDomainSnapshotObjPtr snap,
bool reuse)
{
- int i;
+ size_t i;
virDomainSnapshotDiskDefPtr snapdisk;
virDomainDiskDefPtr defdisk;
virCommandPtr cmd = NULL;
@@ -11883,7 +11888,7 @@ qemuDomainSnapshotPrepare(virDomainObjPtr vm,
virDomainSnapshotDefPtr def,
unsigned int *flags)
{
int ret = -1;
- int i;
+ size_t i;
bool active = virDomainObjIsActive(vm);
struct stat st;
bool reuse = (*flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
@@ -12168,7 +12173,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virJSONValuePtr actions = NULL;
int ret = -1;
- int i;
+ size_t i;
bool persist = false;
bool reuse = (flags & VIR_DOMAIN_SNAPSHOT_CREATE_REUSE_EXT) != 0;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -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 ==
@@ -12247,6 +12253,7 @@ qemuDomainSnapshotCreateDiskActive(virQEMUDriverPtr driver,
snap->def->dom->disks[i],
vm->def->disks[i],
persistDisk,
+
need_unlink);
}
}
@@ -13836,7 +13843,7 @@ qemuDomainOpenConsole(virDomainPtr dom,
{
virDomainObjPtr vm = NULL;
int ret = -1;
- int i;
+ size_t i;
virDomainChrDefPtr chr = NULL;
qemuDomainObjPrivatePtr priv;
@@ -13918,7 +13925,7 @@ qemuDomainOpenChannel(virDomainPtr dom,
{
virDomainObjPtr vm = NULL;
int ret = -1;
- int i;
+ size_t i;
virDomainChrDefPtr chr = NULL;
qemuDomainObjPrivatePtr priv;
@@ -13986,19 +13993,19 @@ cleanup:
}
static char *
-qemuDiskPathToAlias(virDomainObjPtr vm, const char *path, int *idx)
+qemuDiskPathToAlias(virDomainObjPtr vm, const char *path, int *idxret)
{
- int i;
+ int idx;
char *ret = NULL;
virDomainDiskDefPtr disk;
- i = virDomainDiskIndexByName(vm->def, path, true);
- if (i < 0)
+ idx = virDomainDiskIndexByName(vm->def, path, true);
+ if (idx < 0)
goto cleanup;
- disk = vm->def->disks[i];
- if (idx)
- *idx = i;
+ disk = vm->def->disks[idx];
+ if (idxret)
+ *idxret = idx;
if (disk->src) {
if (virAsprintf(&ret, "drive-%s", disk->info.alias) < 0) {
@@ -14824,7 +14831,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
virDomainBlockIoTuneInfo *oldinfo;
const char *device = NULL;
int ret = -1;
- int i;
+ size_t i;
int idx = -1;
bool set_bytes = false;
bool set_iops = false;
@@ -15002,7 +15009,7 @@ qemuDomainGetBlockIoTune(virDomainPtr dom,
virDomainBlockIoTuneInfo reply;
const char *device = NULL;
int ret = -1;
- int i;
+ size_t i;
virCapsPtr caps = NULL;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
@@ -15135,7 +15142,7 @@ qemuDomainGetDiskErrors(virDomainPtr dom,
qemuDomainObjPrivatePtr priv;
virHashTablePtr table = NULL;
int ret = -1;
- int i;
+ size_t i;
int n = 0;
virCheckFlags(0, -1);
@@ -15435,7 +15442,7 @@ getSumVcpuPercpuStats(virDomainObjPtr vm,
unsigned int num)
{
int ret = -1;
- int i;
+ size_t i;
char *buf = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr group_vcpu = NULL;
@@ -15443,7 +15450,7 @@ getSumVcpuPercpuStats(virDomainObjPtr vm,
for (i = 0; i < priv->nvcpupids; i++) {
char *pos;
unsigned long long tmp;
- int j;
+ size_t j;
if (virCgroupNewVcpu(priv->cgroup, i, false, &group_vcpu) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -15483,7 +15490,8 @@ qemuDomainGetPercpuStats(virDomainObjPtr vm,
unsigned int ncpus)
{
int rv = -1;
- int i, id, max_id;
+ size_t i;
+ int id, max_id;
char *pos;
char *buf = NULL;
unsigned long long *sum_cpu_time = NULL;
diff --git a/src/qemu/qemu_hostdev.c b/src/qemu/qemu_hostdev.c
index 404939e..9bdace1 100644
--- a/src/qemu/qemu_hostdev.c
+++ b/src/qemu/qemu_hostdev.c
@@ -38,7 +38,7 @@ static virPCIDeviceListPtr
qemuGetPciHostDeviceList(virDomainHostdevDefPtr *hostdevs, int nhostdevs)
{
virPCIDeviceListPtr list;
- int i;
+ size_t i;
if (!(list = virPCIDeviceListNew()))
return NULL;
@@ -100,7 +100,7 @@ qemuGetActivePciHostDeviceList(virQEMUDriverPtr driver,
int nhostdevs)
{
virPCIDeviceListPtr list;
- int i;
+ size_t i;
if (!(list = virPCIDeviceListNew()))
return NULL;
@@ -133,7 +133,7 @@ int qemuUpdateActivePciHostdevs(virQEMUDriverPtr driver,
{
virDomainHostdevDefPtr hostdev = NULL;
virPCIDevicePtr dev = NULL;
- int i;
+ size_t i;
int ret = -1;
if (!def->nhostdevs)
@@ -193,7 +193,7 @@ qemuUpdateActiveUsbHostdevs(virQEMUDriverPtr driver,
virDomainDefPtr def)
{
virDomainHostdevDefPtr hostdev = NULL;
- int i;
+ size_t i;
int ret = -1;
if (!def->nhostdevs)
@@ -238,7 +238,7 @@ qemuUpdateActiveScsiHostdevs(virQEMUDriverPtr driver,
virDomainDefPtr def)
{
virDomainHostdevDefPtr hostdev = NULL;
- int i;
+ size_t i;
int ret = -1;
if (!def->nhostdevs)
@@ -482,7 +482,7 @@ int qemuPrepareHostdevPCIDevices(virQEMUDriverPtr driver,
{
virPCIDeviceListPtr pcidevs;
int last_processed_hostdev_vf = -1;
- int i;
+ size_t i;
int ret = -1;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -675,7 +675,7 @@ qemuPrepareHostdevUSBDevices(virQEMUDriverPtr driver,
const char *name,
virUSBDeviceListPtr list)
{
- int i, j;
+ size_t i, j;
unsigned int count;
virUSBDevicePtr tmp;
@@ -814,7 +814,8 @@ qemuPrepareHostUSBDevices(virQEMUDriverPtr driver,
virDomainDefPtr def,
bool coldBoot)
{
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
virUSBDeviceListPtr list;
virUSBDevicePtr tmp;
virDomainHostdevDefPtr *hostdevs = def->hostdevs;
@@ -883,7 +884,8 @@ qemuPrepareHostdevSCSIDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
- int i, j, count;
+ size_t i, j;
+ int count;
virSCSIDeviceListPtr list;
virSCSIDevicePtr tmp;
@@ -1056,7 +1058,7 @@ void qemuDomainReAttachHostdevDevices(virQEMUDriverPtr driver,
int nhostdevs)
{
virPCIDeviceListPtr pcidevs;
- int i;
+ size_t i;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virObjectLock(driver->activePciHostdevs);
@@ -1145,7 +1147,7 @@ qemuDomainReAttachHostUsbDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
- int i;
+ size_t i;
virObjectLock(driver->activeUsbHostdevs);
for (i = 0; i < nhostdevs; i++) {
@@ -1208,7 +1210,7 @@ qemuDomainReAttachHostScsiDevices(virQEMUDriverPtr driver,
virDomainHostdevDefPtr *hostdevs,
int nhostdevs)
{
- int i;
+ size_t i;
virObjectLock(driver->activeScsiHostdevs);
for (i = 0; i < nhostdevs; i++) {
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index a350059..162fb03 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -182,7 +182,7 @@ qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver,
qemuDomainObjPrivatePtr priv = vm->privateData;
virHashTablePtr table = NULL;
int ret = -1;
- int i;
+ size_t i;
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) == 0) {
table = qemuMonitorGetBlockInfo(priv->mon);
@@ -221,7 +221,8 @@ int qemuDomainAttachVirtioDiskDevice(virConnectPtr conn,
virDomainObjPtr vm,
virDomainDiskDefPtr disk)
{
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
const char* type = virDomainDiskBusTypeToString(disk->bus);
qemuDomainObjPrivatePtr priv = vm->privateData;
char *devstr = NULL;
@@ -425,7 +426,7 @@ qemuDomainFindOrCreateSCSIDiskController(virQEMUDriverPtr driver,
virDomainObjPtr vm,
int controller)
{
- int i;
+ size_t i;
virDomainControllerDefPtr cont;
for (i = 0; i < vm->def->ncontrollers; i++) {
@@ -472,7 +473,7 @@ int qemuDomainAttachSCSIDisk(virConnectPtr conn,
virDomainObjPtr vm,
virDomainDiskDefPtr disk)
{
- int i;
+ size_t i;
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainControllerDefPtr cont = NULL;
char *drivestr = NULL;
@@ -598,7 +599,8 @@ int qemuDomainAttachUsbMassstorageDevice(virConnectPtr conn,
virDomainDiskDefPtr disk)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
char *drivestr = NULL;
char *devstr = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
@@ -708,7 +710,7 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
bool iface_connected = false;
int actualType;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- int i;
+ size_t i;
/* preallocate new slot for device */
if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets+1) < 0) {
@@ -832,12 +834,12 @@ int qemuDomainAttachNetDevice(virConnectPtr conn,
}
for (i = 0; i < tapfdSize; i++) {
- if (virAsprintf(&tapfdName[i], "fd-%s%d", net->info.alias, i)
< 0)
+ if (virAsprintf(&tapfdName[i], "fd-%s%zu", net->info.alias, i)
< 0)
goto no_memory;
}
for (i = 0; i < vhostfdSize; i++) {
- if (virAsprintf(&vhostfdName[i], "vhostfd-%s%d",
net->info.alias, i) < 0)
+ if (virAsprintf(&vhostfdName[i], "vhostfd-%s%zu",
net->info.alias, i) < 0)
goto no_memory;
}
@@ -1387,7 +1389,7 @@ cleanup:
static virDomainNetDefPtr *qemuDomainFindNet(virDomainObjPtr vm,
virDomainNetDefPtr dev)
{
- int i;
+ size_t i;
for (i = 0; i < vm->def->nnets; i++) {
if (virMacAddrCmp(&vm->def->nets[i]->mac, &dev->mac) == 0)
@@ -1941,7 +1943,7 @@ cleanup:
static virDomainGraphicsDefPtr qemuDomainFindGraphics(virDomainObjPtr vm,
virDomainGraphicsDefPtr dev)
{
- int i;
+ size_t i;
for (i = 0; i < vm->def->ngraphics; i++) {
if (vm->def->graphics[i]->type == dev->type)
@@ -2123,7 +2125,7 @@ cleanup:
static inline int qemuFindDisk(virDomainDefPtr def, const char *dst)
{
- int i;
+ size_t i;
for (i = 0; i < def->ndisks; i++) {
if (STREQ(def->disks[i]->dst, dst)) {
@@ -2166,20 +2168,21 @@ int qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
{
- int i, ret = -1;
+ int idx;
+ int ret = -1;
virDomainDiskDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
char *drivestr = NULL;
- i = qemuFindDisk(vm->def, dev->data.disk->dst);
+ idx = qemuFindDisk(vm->def, dev->data.disk->dst);
- if (i < 0) {
+ if (idx < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("disk %s not found"), dev->data.disk->dst);
goto cleanup;
}
- detach = vm->def->disks[i];
+ detach = vm->def->disks[idx];
if (qemuIsMultiFunctionDevice(vm->def, &detach->info)) {
virReportError(VIR_ERR_OPERATION_FAILED,
@@ -2247,7 +2250,7 @@ int qemuDomainDetachVirtioDiskDevice(virQEMUDriverPtr driver,
&detach->info.addr.pci) < 0)
VIR_WARN("Unable to release PCI address on %s",
dev->data.disk->src);
- virDomainDiskRemove(vm->def, i);
+ virDomainDiskRemove(vm->def, idx);
dev->data.disk->backingChain = detach->backingChain;
detach->backingChain = NULL;
@@ -2275,14 +2278,15 @@ int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDeviceDefPtr dev)
{
- int i, ret = -1;
+ int idx;
+ int ret = -1;
virDomainDiskDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
char *drivestr = NULL;
- i = qemuFindDisk(vm->def, dev->data.disk->dst);
+ idx = qemuFindDisk(vm->def, dev->data.disk->dst);
- if (i < 0) {
+ if (idx < 0) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("disk %s not found"), dev->data.disk->dst);
goto cleanup;
@@ -2295,7 +2299,7 @@ int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
goto cleanup;
}
- detach = vm->def->disks[i];
+ detach = vm->def->disks[idx];
if (detach->mirror) {
virReportError(VIR_ERR_BLOCK_COPY_ACTIVE,
@@ -2326,7 +2330,7 @@ int qemuDomainDetachDiskDevice(virQEMUDriverPtr driver,
virDomainAuditDisk(vm, detach->src, NULL, "detach", true);
- virDomainDiskRemove(vm->def, i);
+ virDomainDiskRemove(vm->def, idx);
dev->data.disk->backingChain = detach->backingChain;
detach->backingChain = NULL;
@@ -2353,7 +2357,7 @@ cleanup:
static bool qemuDomainDiskControllerIsBusy(virDomainObjPtr vm,
virDomainControllerDefPtr detach)
{
- int i;
+ size_t i;
virDomainDiskDefPtr disk;
for (i = 0; i < vm->def->ndisks; i++) {
@@ -3016,9 +3020,9 @@ int qemuDomainDetachLease(virQEMUDriverPtr driver,
virDomainLeaseDefPtr lease)
{
virDomainLeaseDefPtr det_lease;
- int i;
+ int idx;
- if ((i = virDomainLeaseIndex(vm->def, lease)) < 0) {
+ if ((idx = virDomainLeaseIndex(vm->def, lease)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
_("Lease %s in lockspace %s does not exist"),
lease->key, NULLSTR(lease->lockspace));
@@ -3028,7 +3032,7 @@ int qemuDomainDetachLease(virQEMUDriverPtr driver,
if (virDomainLockLeaseDetach(driver->lockManager, vm, lease) < 0)
return -1;
- det_lease = virDomainLeaseRemoveAt(vm->def, i);
+ det_lease = virDomainLeaseRemoveAt(vm->def, idx);
virDomainLeaseDefFree(det_lease);
return 0;
}
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index a6b7acb..387147b 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -183,7 +183,7 @@ static void
qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphicsPtr grap)
static void
qemuMigrationCookieNetworkFree(qemuMigrationCookieNetworkPtr network)
{
- int i;
+ size_t i;
if (!network)
return;
@@ -338,7 +338,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver
ATTRIBUTE_UNUSED,
virDomainDefPtr def)
{
qemuMigrationCookieNetworkPtr mig;
- int i;
+ size_t i;
if (VIR_ALLOC(mig) < 0)
goto no_memory;
@@ -567,7 +567,7 @@ static void
qemuMigrationCookieNetworkXMLFormat(virBufferPtr buf,
qemuMigrationCookieNetworkPtr optr)
{
- int i;
+ size_t i;
bool empty = true;
for (i = 0; i < optr->nnets; i++) {
@@ -577,7 +577,7 @@ qemuMigrationCookieNetworkXMLFormat(virBufferPtr buf,
virBufferAddLit(buf, " <network>\n");
empty = false;
}
- virBufferAsprintf(buf, " <interface index='%d'
vporttype='%s'",
+ virBufferAsprintf(buf, " <interface index='%zu'
vporttype='%s'",
i, virNetDevVPortTypeToString(optr->net[i].vporttype));
if (optr->net[i].portdata) {
virBufferAddLit(buf, ">\n");
@@ -601,7 +601,7 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver,
{
char uuidstr[VIR_UUID_STRING_BUFLEN];
char hostuuidstr[VIR_UUID_STRING_BUFLEN];
- int i;
+ size_t i;
virUUIDFormat(mig->uuid, uuidstr);
virUUIDFormat(mig->localHostuuid, hostuuidstr);
@@ -734,7 +734,7 @@ static qemuMigrationCookieNetworkPtr
qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt)
{
qemuMigrationCookieNetworkPtr optr;
- int i;
+ size_t i;
int n;
xmlNodePtr *interfaces = NULL;
char *vporttype;
@@ -792,7 +792,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig,
char uuidstr[VIR_UUID_STRING_BUFLEN];
char *tmp = NULL;
xmlNodePtr *nodes = NULL;
- int i, n;
+ size_t i;
+ int n;
virCapsPtr caps = NULL;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
@@ -1430,7 +1431,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
int nsnapshots;
int pauseReason;
bool forbid;
- int i;
+ size_t i;
if (vm) {
if (qemuProcessAutoDestroyActive(driver, vm)) {
@@ -1496,7 +1497,7 @@ qemuMigrationIsAllowed(virQEMUDriverPtr driver, virDomainObjPtr vm,
static bool
qemuMigrationIsSafe(virDomainDefPtr def)
{
- int i;
+ size_t i;
for (i = 0; i < def->ndisks; i++) {
virDomainDiskDefPtr disk = def->disks[i];
@@ -1828,7 +1829,7 @@ qemuDomainMigrateGraphicsRelocate(virQEMUDriverPtr driver,
}
if (uri) {
- int i;
+ size_t i;
if ((type = virDomainGraphicsTypeFromString(uri->scheme)) < 0) {
virReportError(VIR_ERR_INVALID_ARG,
@@ -1885,7 +1886,7 @@ qemuDomainMigrateOPDRelocate(virQEMUDriverPtr driver
ATTRIBUTE_UNUSED,
{
virDomainNetDefPtr netptr;
int ret = -1;
- int i;
+ size_t i;
for (i = 0; i < cookie->network->nnets; i++) {
netptr = vm->def->nets[i];
@@ -4286,7 +4287,7 @@ qemuMigrationPerform(virQEMUDriverPtr driver,
static int
qemuMigrationVPAssociatePortProfiles(virDomainDefPtr def) {
- int i;
+ size_t i;
int last_good_net = -1;
virDomainNetDefPtr net;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index fe5ab0a..56c7b20 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -133,7 +133,7 @@ VIR_ENUM_IMPL(qemuMonitorBlockIOStatus,
char *qemuMonitorEscapeArg(const char *in)
{
int len = 0;
- int i, j;
+ size_t i, j;
char *out;
/* To pass through the QEMU monitor, we need to use escape
@@ -184,7 +184,7 @@ char *qemuMonitorEscapeArg(const char *in)
char *qemuMonitorUnescapeArg(const char *in)
{
- int i, j;
+ size_t i, j;
char *out;
int len = strlen(in);
char next;
@@ -224,7 +224,7 @@ char *qemuMonitorUnescapeArg(const char *in)
# include <c-ctype.h>
static char * qemuMonitorEscapeNonPrintable(const char *text)
{
- int i;
+ size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
for (i = 0; text[i] != '\0'; i++) {
if (c_isprint(text[i]) ||
@@ -257,7 +257,8 @@ qemuMonitorOpenUnix(const char *monitor, pid_t cpid)
struct sockaddr_un addr;
int monfd;
int timeout = 3; /* In seconds */
- int ret, i = 0;
+ int ret;
+ size_t i = 0;
if ((monfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
virReportSystemError(errno,
@@ -2491,7 +2492,7 @@ int qemuMonitorAddHostNetwork(qemuMonitorPtr mon,
int *vhostfd, char **vhostfdName, int vhostfdSize)
{
int ret = -1;
- int i = 0, j = 0;
+ size_t i = 0, j = 0;
VIR_DEBUG("mon=%p netstr=%s tapfd=%p tapfdName=%p tapfdSize=%d "
"vhostfd=%p vhostfdName=%p vhostfdSize=%d",
@@ -2564,7 +2565,7 @@ int qemuMonitorAddNetdev(qemuMonitorPtr mon,
int *vhostfd, char **vhostfdName, int vhostfdSize)
{
int ret = -1;
- int i = 0, j = 0;
+ size_t i = 0, j = 0;
VIR_DEBUG("mon=%p netdevstr=%s tapfd=%p tapfdName=%p tapfdSize=%d"
"vhostfd=%p vhostfdName=%p vhostfdSize=%d",
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 3383c88..5a70a87 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -514,7 +514,7 @@ error:
static void
qemuFreeKeywords(int nkeywords, char **keywords, char **values)
{
- int i;
+ size_t i;
for (i = 0; i < nkeywords; i++) {
VIR_FREE(keywords[i]);
VIR_FREE(values[i]);
@@ -530,7 +530,7 @@ qemuMonitorJSONKeywordStringToJSON(const char *str, const char
*firstkeyword)
char **keywords = NULL;
char **values = NULL;
int nkeywords = 0;
- int i;
+ size_t i;
if (!(ret = virJSONValueNewObject()))
goto no_memory;
@@ -1004,7 +1004,8 @@ qemuMonitorJSONStartCPUs(qemuMonitorPtr mon,
int ret;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("cont", NULL);
virJSONValuePtr reply = NULL;
- int i = 0, timeout = 3;
+ size_t i = 0;
+ int timeout = 3;
if (!cmd)
return -1;
@@ -1180,7 +1181,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
{
virJSONValuePtr data;
int ret = -1;
- int i;
+ size_t i;
int *threads = NULL;
int ncpus;
@@ -1499,7 +1500,7 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
virHashTablePtr table)
{
int ret;
- int i;
+ size_t i;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-block",
NULL);
@@ -1605,7 +1606,7 @@ int qemuMonitorJSONGetBlockStatsInfo(qemuMonitorPtr mon,
long long *errs)
{
int ret;
- int i;
+ size_t i;
bool found = false;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-blockstats",
NULL);
@@ -1755,7 +1756,8 @@ cleanup:
int qemuMonitorJSONGetBlockStatsParamsNumber(qemuMonitorPtr mon,
int *nparams)
{
- int ret, i, num = 0;
+ int ret, num = 0;
+ size_t i;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-blockstats",
NULL);
virJSONValuePtr reply = NULL;
@@ -1829,7 +1831,7 @@ int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
unsigned long long *extent)
{
int ret = -1;
- int i;
+ size_t i;
bool found = false;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-blockstats",
NULL);
@@ -2941,7 +2943,7 @@ static int qemuMonitorJSONExtractPtyPaths(virJSONValuePtr reply,
{
virJSONValuePtr data;
int ret = -1;
- int i;
+ size_t i;
if (!(data = virJSONValueObjectGet(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -3408,7 +3410,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL;
virJSONValuePtr keys = NULL;
virJSONValuePtr key = NULL;
- unsigned int i;
+ size_t i;
/* create the key data array */
if (!(keys = virJSONValueNewArray()))
@@ -3417,7 +3419,7 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon,
for (i = 0; i < nkeycodes; i++) {
if (keycodes[i] > 0xffff) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("keycode %d is invalid: 0x%X"), i, keycodes[i]);
+ _("keycode %zu is invalid: 0x%X"), i, keycodes[i]);
goto cleanup;
}
@@ -3553,7 +3555,8 @@ static int qemuMonitorJSONGetBlockJobInfo(virJSONValuePtr reply,
virDomainBlockJobInfoPtr info)
{
virJSONValuePtr data;
- int nr_results, i;
+ int nr_results;
+ size_t i;
if (!info)
return -1;
@@ -3729,7 +3732,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
{
virJSONValuePtr io_throttle;
int ret = -1;
- int i;
+ size_t i;
bool found = false;
io_throttle = virJSONValueObjectGet(result, "return");
@@ -4668,7 +4671,7 @@ qemuMonitorJSONGetMigrationCapability(qemuMonitorPtr mon,
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr caps;
- int i;
+ size_t i;
if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-capabilities",
NULL)))
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 15fbcb7..3c6f3b4 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -157,7 +157,7 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
VIR_DEBUG("Seen a password prompt [%s]", data + used);
#endif
if (msg->passwordHandler) {
- int i;
+ size_t i;
/* Try and handle the prompt. The handler is required
* to report a normal libvirt error */
if (msg->passwordHandler(mon, msg,
@@ -2976,7 +2976,7 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
unsigned int *keycodes,
unsigned int nkeycodes)
{
- int i;
+ size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER;
char *cmd, *reply = NULL;
int ret = -1;
@@ -2988,7 +2988,7 @@ int qemuMonitorTextSendKey(qemuMonitorPtr mon,
for (i = 0; i < nkeycodes; i++) {
if (keycodes[i] > 0xffff) {
virReportError(VIR_ERR_OPERATION_FAILED,
- _("keycode %d is invalid: 0x%X"),
+ _("keycode %zu is invalid: 0x%X"),
i, keycodes[i]);
virBufferFreeAndReset(&buf);
return -1;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f8c652f..2b3eca0 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -197,7 +197,7 @@ static virDomainChrSourceDefPtr
qemuFindAgentConfig(virDomainDefPtr def)
{
virDomainChrSourceDefPtr config = NULL;
- int i;
+ size_t i;
for (i = 0; i < def->nchannels; i++) {
virDomainChrDefPtr channel = def->channels[i];
@@ -365,10 +365,10 @@ static virDomainDiskDefPtr
qemuProcessFindDomainDiskByPath(virDomainObjPtr vm,
const char *path)
{
- int i = virDomainDiskIndexByName(vm->def, path, true);
+ int idx = virDomainDiskIndexByName(vm->def, path, true);
- if (i >= 0)
- return vm->def->disks[i];
+ if (idx >= 0)
+ return vm->def->disks[idx];
virReportError(VIR_ERR_INTERNAL_ERROR,
_("no disk found with path %s"),
@@ -380,7 +380,7 @@ static virDomainDiskDefPtr
qemuProcessFindDomainDiskByAlias(virDomainObjPtr vm,
const char *alias)
{
- int i;
+ size_t i;
if (STRPREFIX(alias, QEMU_DRIVE_HOST_PREFIX))
alias += strlen(QEMU_DRIVE_HOST_PREFIX);
@@ -1020,7 +1020,7 @@ qemuProcessHandleGraphics(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainEventGraphicsAddressPtr localAddr = NULL;
virDomainEventGraphicsAddressPtr remoteAddr = NULL;
virDomainEventGraphicsSubjectPtr subject = NULL;
- int i;
+ size_t i;
if (VIR_ALLOC(localAddr) < 0)
goto no_memory;
@@ -1565,7 +1565,7 @@ qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
virHashTablePtr paths,
bool chardevfmt)
{
- int i;
+ size_t i;
const char *prefix = chardevfmt ? "char" : "";
for (i = 0; i < count; i++) {
@@ -1610,7 +1610,7 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
virHashTablePtr paths)
{
bool chardevfmt = virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV);
- int i = 0;
+ size_t i = 0;
if (qemuProcessLookupPTYs(vm->def->serials, vm->def->nserials,
paths, chardevfmt) < 0)
@@ -1652,7 +1652,8 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,
int fd ATTRIBUTE_UNUSED)
{
size_t offset = 0;
- int ret, i;
+ int ret;
+ size_t i;
/* The order in which QEMU prints out the PTY paths is
the order in which it procsses its serial and parallel
@@ -1852,7 +1853,8 @@ virBitmapPtr
qemuPrepareCpumap(virQEMUDriverPtr driver,
virBitmapPtr nodemask)
{
- int i, hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
+ size_t i;
+ int hostcpus, maxcpu = QEMUD_CPUMASK_LEN;
virBitmapPtr cpumap = NULL;
virCapsPtr caps = NULL;
@@ -1877,7 +1879,7 @@ qemuPrepareCpumap(virQEMUDriverPtr driver,
}
for (i = 0; i < caps->host.nnumaCell; i++) {
- int j;
+ size_t j;
int cur_ncpus = caps->host.numaCell[i]->ncpus;
bool result;
if (virBitmapGetBit(nodemask, i, &result) < 0) {
@@ -1952,7 +1954,7 @@ qemuProcessSetLinkStates(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDefPtr def = vm->def;
- int i;
+ size_t i;
int ret = 0;
for (i = 0; i < def->nnets; i++) {
@@ -2040,7 +2042,7 @@ qemuProcessInitPasswords(virConnectPtr conn,
int ret = 0;
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
- int i;
+ size_t i;
for (i = 0; i < vm->def->ngraphics; ++i) {
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
@@ -2131,7 +2133,7 @@ qemuProcessAssignNextPCIAddress(virDomainDeviceInfo *info,
int naddrs)
{
bool found = false;
- int i;
+ size_t i;
VIR_DEBUG("Look for %x:%x out of %d", vendor, product, naddrs);
@@ -2139,7 +2141,7 @@ qemuProcessAssignNextPCIAddress(virDomainDeviceInfo *info,
VIR_DEBUG("Maybe %x:%x", addrs[i].vendor, addrs[i].product);
if (addrs[i].vendor == vendor &&
addrs[i].product == product) {
- VIR_DEBUG("Match %d", i);
+ VIR_DEBUG("Match %zu", i);
found = true;
break;
}
@@ -2345,7 +2347,7 @@ qemuProcessDetectPCIAddresses(virDomainObjPtr vm,
int naddrs)
{
unsigned int vendor = 0, product = 0;
- int i;
+ size_t i;
/* XXX should all these vendor/product IDs be kept in the
* actual device data structure instead ?
@@ -2661,10 +2663,10 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, virDomainObjPtr
vm,
static int
qemuProcessNotifyNets(virDomainDefPtr def)
{
- int ii;
+ size_t i;
- for (ii = 0; ii < def->nnets; ii++) {
- virDomainNetDefPtr net = def->nets[ii];
+ for (i = 0; i < def->nnets; i++) {
+ virDomainNetDefPtr net = def->nets[i];
if (networkNotifyActualDevice(net) < 0)
return -1;
}
@@ -2675,7 +2677,7 @@ static int
qemuProcessFiltersInstantiate(virConnectPtr conn,
virDomainDefPtr def)
{
- int i;
+ size_t i;
if (!conn)
return 1;
@@ -3282,7 +3284,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
{
unsigned short port = 0;
unsigned short tlsPort;
- int i;
+ size_t i;
int defaultMode = graphics->data.spice.defaultMode;
bool needTLSPort = false;
@@ -3410,7 +3412,7 @@ int qemuProcessStart(virConnectPtr conn,
virCommandPtr cmd = NULL;
struct qemuProcessHookData hookData;
unsigned long cur_balloon;
- int i;
+ size_t i;
char *nodeset = NULL;
virBitmapPtr nodemask = NULL;
unsigned int stop_flags;
@@ -4022,7 +4024,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
virErrorPtr orig_err;
virDomainDefPtr def;
virNetDevVPortProfilePtr vport = NULL;
- int i;
+ size_t i;
int logfile = -1;
char *timestamp;
char ebuf[1024];
--
1.8.1.4