diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 5aeb2ab7d7efe88872037222c2d875c8afb33a84..bb5fe4ec60f915cb9668cbef82dde8f4479d8916 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -123,7 +123,7 @@ virCapabilitiesFreeGuestMachine(virCapsGuestMachinePtr machine) static void virCapabilitiesFreeGuestDomain(virCapsGuestDomainPtr dom) { - int i; + size_t i; if (dom == NULL) return; @@ -149,7 +149,7 @@ virCapabilitiesFreeGuestFeature(virCapsGuestFeaturePtr feature) static void virCapabilitiesFreeGuest(virCapsGuestPtr guest) { - int i; + size_t i; if (guest == NULL) return; @@ -175,7 +175,7 @@ virCapabilitiesFreeGuest(virCapsGuestPtr guest) void virCapabilitiesFreeNUMAInfo(virCapsPtr caps) { - int i; + size_t i; for (i = 0; i < caps->host.nnumaCell; i++) virCapabilitiesFreeHostNUMACell(caps->host.numaCell[i]); @@ -187,7 +187,7 @@ static void virCapabilitiesDispose(void *object) { virCapsPtr caps = object; - int i; + size_t i; for (i = 0; i < caps->nguests; i++) virCapabilitiesFreeGuest(caps->guests[i]); @@ -327,7 +327,7 @@ virCapsGuestMachinePtr * virCapabilitiesAllocMachines(const char *const *names, int nnames) { virCapsGuestMachinePtr *machines; - int i; + size_t i; if (VIR_ALLOC_N(machines, nnames) < 0) return NULL; @@ -353,7 +353,7 @@ void virCapabilitiesFreeMachines(virCapsGuestMachinePtr *machines, int nmachines) { - int i; + size_t i; if (!machines) return; for (i = 0; i < nmachines && machines[i]; i++) { @@ -518,7 +518,7 @@ extern int virCapabilitiesSupportsGuestArch(virCapsPtr caps, virArch arch) { - int i; + size_t i; for (i = 0; i < caps->nguests; i++) { if (caps->guests[i]->arch.id == arch) return 1; @@ -539,7 +539,7 @@ extern int virCapabilitiesSupportsGuestOSType(virCapsPtr caps, const char *ostype) { - int i; + size_t i; for (i = 0; i < caps->nguests; i++) { if (STREQ(caps->guests[i]->ostype, ostype)) return 1; @@ -562,7 +562,7 @@ virCapabilitiesSupportsGuestOSTypeArch(virCapsPtr caps, const char *ostype, virArch arch) { - int i; + size_t i; for (i = 0; i < caps->nguests; i++) { if (STREQ(caps->guests[i]->ostype, ostype) && caps->guests[i]->arch.id == arch) @@ -585,7 +585,7 @@ virCapabilitiesDefaultGuestArch(virCapsPtr caps, const char *ostype, const char *domain) { - int i, j; + size_t i, j; /* First try to find one matching host arch */ for (i = 0; i < caps->nguests; i++) { @@ -628,11 +628,11 @@ virCapabilitiesDefaultGuestMachine(virCapsPtr caps, virArch arch, const char *domain) { - int i; + size_t i; for (i = 0; i < caps->nguests; i++) { virCapsGuestPtr guest = caps->guests[i]; - int j; + size_t j; if (!STREQ(guest->ostype, ostype) || guest->arch.id != arch) @@ -674,7 +674,7 @@ virCapabilitiesDefaultGuestEmulator(virCapsPtr caps, virArch arch, const char *domain) { - int i, j; + size_t i, j; for (i = 0; i < caps->nguests; i++) { char *emulator; if (STREQ(caps->guests[i]->ostype, ostype) && @@ -697,8 +697,8 @@ virCapabilitiesFormatNUMATopology(virBufferPtr xml, size_t ncells, virCapsHostNUMACellPtr *cells) { - int i; - int j; + size_t i; + size_t j; char *siblings; virBufferAddLit(xml, " \n"); @@ -754,7 +754,7 @@ char * virCapabilitiesFormatXML(virCapsPtr caps) { virBuffer xml = VIR_BUFFER_INITIALIZER; - int i, j, k; + size_t i, j, k; char host_uuid[VIR_UUID_STRING_BUFLEN]; virBufferAddLit(&xml, "\n\n"); diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index 16e2d529ac22ef212fab546f92842044e1e738c1..23e76386714f3257dcfd66018293cad1df9f69b4 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -60,7 +60,7 @@ VIR_ENUM_IMPL(virCPUFeaturePolicy, VIR_CPU_FEATURE_LAST, void ATTRIBUTE_NONNULL(1) virCPUDefFreeModel(virCPUDefPtr def) { - unsigned int i; + size_t i; VIR_FREE(def->model); VIR_FREE(def->vendor); @@ -74,7 +74,7 @@ virCPUDefFreeModel(virCPUDefPtr def) void virCPUDefFree(virCPUDefPtr def) { - unsigned int i; + size_t i; if (!def) return; @@ -97,7 +97,7 @@ virCPUDefCopyModel(virCPUDefPtr dst, const virCPUDefPtr src, bool resetPolicy) { - unsigned int i; + size_t i; if (VIR_STRDUP(dst->model, src->model) < 0 || VIR_STRDUP(dst->vendor, src->vendor) < 0 || @@ -129,7 +129,7 @@ virCPUDefPtr virCPUDefCopy(const virCPUDefPtr cpu) { virCPUDefPtr copy; - unsigned int i; + size_t i; if (!cpu || VIR_ALLOC(copy) < 0) return NULL; @@ -181,7 +181,7 @@ virCPUDefParseXML(const xmlNodePtr node, virCPUDefPtr def; xmlNodePtr *nodes = NULL; int n; - unsigned int i; + size_t i; char *cpuMode; char *fallback = NULL; char *vendor_id = NULL; @@ -379,7 +379,7 @@ virCPUDefParseXML(const xmlNodePtr node, for (i = 0; i < n; i++) { char *name; int policy; /* enum virDomainCPUFeaturePolicy */ - unsigned int j; + size_t j; if (def->type == VIR_CPU_TYPE_GUEST) { char *strpolicy; @@ -562,7 +562,7 @@ virCPUDefFormatBuf(virBufferPtr buf, virCPUDefPtr def, unsigned int flags) { - unsigned int i; + size_t i; bool formatModel; bool formatFallback; @@ -663,7 +663,7 @@ virCPUDefAddFeature(virCPUDefPtr def, const char *name, int policy) { - int i; + size_t i; for (i = 0; i < def->nfeatures; i++) { if (STREQ(name, def->features[i].name)) { @@ -694,7 +694,7 @@ virCPUDefIsEqual(virCPUDefPtr src, virCPUDefPtr dst) { bool identical = false; - int i; + size_t i; if (!src && !dst) return true; diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index e53daf8b9180854b4b551849298b074bcbec1b32..11cf5c8e7b55c2f02ec1a32b861ba5d53f68b5d0 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -793,7 +793,7 @@ virDomainAuditLifecycle(virDomainObjPtr vm, const char *op, void virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success) { - int i; + size_t i; for (i = 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk = vm->def->disks[i]; @@ -874,7 +874,7 @@ virDomainAuditSecurityLabel(virDomainObjPtr vm, bool success) char uuidstr[VIR_UUID_STRING_BUFLEN]; char *vmname; const char *virt; - int i; + size_t i; virUUIDFormat(vm->def->uuid, uuidstr); if (!(vmname = virAuditEncode("vm", vm->def->name))) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3398d8b184ecec67f555b769b5db0396b2edb067..4013267ffc4e0b3cd3c904b0e966e40b4b1bbf26 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -869,7 +869,7 @@ void virBlkioDeviceWeightArrayClear(virBlkioDeviceWeightPtr deviceWeights, int ndevices) { - int i; + size_t i; for (i = 0; i < ndevices; i++) VIR_FREE(deviceWeights[i].path); @@ -1101,7 +1101,7 @@ virSecurityDeviceLabelDefFree(virSecurityDeviceLabelDefPtr def) void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def) { - int ii; + size_t i; if (!def) return; @@ -1131,8 +1131,8 @@ void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def) break; } - for (ii = 0; ii < def->nListens; ii++) - virDomainGraphicsListenDefClear(&def->listens[ii]); + for (i = 0; i < def->nListens; i++) + virDomainGraphicsListenDefClear(&def->listens[i]); VIR_FREE(def->listens); VIR_FREE(def); @@ -1173,7 +1173,7 @@ virDomainDiskSourcePoolDefFree(virDomainDiskSourcePoolDefPtr def) void virDomainDiskDefFree(virDomainDiskDefPtr def) { - unsigned int i; + size_t i; if (!def) return; @@ -1550,7 +1550,7 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def) virDomainDeviceInfoClear(&def->info); - int i; + size_t i; for (i = 0; i < def->ncodecs; i++) virDomainSoundCodecDefFree(def->codecs[i]); VIR_FREE(def->codecs); @@ -1775,7 +1775,7 @@ virDomainClockDefClear(virDomainClockDefPtr def) if (def->offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE) VIR_FREE(def->data.timezone); - int i; + size_t i; for (i = 0; i < def->ntimers; i++) VIR_FREE(def->timers[i]); VIR_FREE(def->timers); @@ -1784,7 +1784,7 @@ virDomainClockDefClear(virDomainClockDefPtr def) virDomainVcpuPinDefPtr * virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin) { - int i = 0; + size_t i; virDomainVcpuPinDefPtr *ret = NULL; if (VIR_ALLOC_N(ret, nvcpupin) < 0) @@ -1802,7 +1802,7 @@ virDomainVcpuPinDefCopy(virDomainVcpuPinDefPtr *src, int nvcpupin) error: if (ret) { - for (; i >= 0; --i) { + for (i = 0; i < nvcpupin; i++) { if (ret[i]) { virBitmapFree(ret[i]->cpumask); VIR_FREE(ret[i]); @@ -1827,7 +1827,7 @@ void virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def, int nvcpupin) { - int i; + size_t i; if (!def || !nvcpupin) return; @@ -1853,7 +1853,7 @@ virDomainResourceDefFree(virDomainResourceDefPtr resource) void virDomainDefFree(virDomainDefPtr def) { - unsigned int i; + size_t i; if (!def) return; @@ -2470,7 +2470,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, bool all, void *opaque) { - int i; + size_t i; virDomainDeviceDef device; device.type = VIR_DOMAIN_DEVICE_DISK; @@ -2637,7 +2637,7 @@ virDomainDefRejectDuplicateControllers(virDomainDefPtr def) size_t nbitmaps = 0; int ret = -1; bool b; - int i; + size_t i; memset(max_idx, -1, sizeof(max_idx)); @@ -2685,7 +2685,7 @@ static int virDomainDefPostParseInternal(virDomainDefPtr def, virCapsPtr caps ATTRIBUTE_UNUSED) { - int i; + size_t i; /* verify init path for container based domains */ if (STREQ(def->os.type, "exe") && !def->os.init) { @@ -3800,7 +3800,7 @@ virDomainDriveAddressIsUsedByDisk(virDomainDefPtr def, unsigned int unit) { virDomainDiskDefPtr disk; - int i; + size_t i; for (i = 0; i < def->ndisks; i++) { disk = def->disks[i]; @@ -3829,7 +3829,7 @@ virDomainDriveAddressIsUsedByHostdev(virDomainDefPtr def, unsigned int unit) { virDomainHostdevDefPtr hostdev; - int i; + size_t i; for (i = 0; i < def->nhostdevs; i++) { hostdev = def->hostdevs[i]; @@ -3873,7 +3873,7 @@ virDomainControllerSCSINextUnit(virDomainDefPtr def, unsigned int max_unit, unsigned int controller) { - int i; + size_t i; for (i = 0; i < max_unit; i++) { if (!virDomainSCSIDriveAddressIsUsed(def, controller, i)) @@ -3893,7 +3893,7 @@ virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt, { int next_unit = 0; unsigned controller = 0; - int i; + size_t i; int ret; if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) @@ -4125,7 +4125,7 @@ virDomainDeviceFindControllerModel(virDomainDefPtr def, int controllerType) { int model = -1; - int i; + size_t i; for (i = 0; i < def->ncontrollers; i++) { if (def->controllers[i]->type == controllerType && @@ -4141,7 +4141,7 @@ virDomainDiskFindByBusAndDst(virDomainDefPtr def, int bus, char *dst) { - int i; + size_t i; if (!dst) return NULL; @@ -4345,7 +4345,8 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, virCapsPtr caps, unsigned int flags) { - int i = 0, n; + size_t i = 0; + int n; xmlNodePtr *list = NULL, saved_node; virCapsHostPtr host = &caps->host; @@ -4434,7 +4435,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn, { virSecurityDeviceLabelDefPtr *seclabels; size_t nseclabels = 0; - int n, i, j; + int n; + size_t i, j; xmlNodePtr *list = NULL; virSecurityLabelDefPtr vmDef = NULL; char *model, *relabel, *label; @@ -5318,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 " @@ -5325,14 +5329,13 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } - int 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) { @@ -5388,9 +5391,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } if (startupPolicy) { - int i; + int val; - if ((i = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) { + if ((val = virDomainStartupPolicyTypeFromString(startupPolicy)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown startupPolicy value '%s'"), startupPolicy); @@ -5405,7 +5408,7 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, startupPolicy); goto error; } - def->startupPolicy = i; + def->startupPolicy = val; } def->src = source; @@ -6469,14 +6472,14 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, def->driver.virtio.txmode = m; } if (ioeventfd) { - int 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; @@ -7092,7 +7095,7 @@ virDomainSmartcardDefParseXML(xmlNodePtr node, char *mode = NULL; char *type = NULL; virDomainSmartcardDefPtr def; - int i; + size_t i; if (VIR_ALLOC(def) < 0) return NULL; @@ -7762,14 +7765,14 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, goto error; if (nListens > 0) { - int ii; + size_t i; if (VIR_ALLOC_N(def->listens, nListens) < 0) goto error; - for (ii = 0; ii < nListens; ii++) { - int ret = virDomainGraphicsListenDefParseXML(&def->listens[ii], - listenNodes[ii], + for (i = 0; i < nListens; i++) { + int ret = virDomainGraphicsListenDefParseXML(&def->listens[i], + listenNodes[i], flags); if (ret < 0) goto error; @@ -7799,12 +7802,12 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, * graphics. */ bool matched = false; const char *found = NULL; - int ii; + size_t i; - for (ii = 0; ii < nListens; ii++) { - if (virDomainGraphicsListenGetType(def, ii) + for (i = 0; i < nListens; i++) { + if (virDomainGraphicsListenGetType(def, i) == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { - found = virDomainGraphicsListenGetAddress(def, ii); + found = virDomainGraphicsListenGetAddress(def, i); if (STREQ_NULLABLE(found, listenAddr)) { matched = true; } @@ -8306,15 +8309,15 @@ virDomainSoundDefParseXML(const xmlNodePtr node, goto error; if (ncodecs > 0) { - int ii; + size_t i; if (VIR_ALLOC_N(def->codecs, ncodecs) < 0) { VIR_FREE(codecNodes); goto error; } - for (ii = 0; ii < ncodecs; ii++) { - virDomainSoundCodecDefPtr codec = virDomainSoundCodecDefParseXML(codecNodes[ii]); + for (i = 0; i < ncodecs; i++) { + virDomainSoundCodecDefPtr codec = virDomainSoundCodecDefParseXML(codecNodes[i]); if (codec == NULL) goto error; @@ -9592,7 +9595,7 @@ virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr *found) { virDomainHostdevDefPtr local_found; - int i; + size_t i; if (!found) found = &local_found; @@ -9612,7 +9615,7 @@ virDomainDiskIndexByName(virDomainDefPtr def, const char *name, bool allow_ambiguous) { virDomainDiskDefPtr vdisk; - int i; + size_t i; int candidate = -1; /* We prefer the name (it's shorter, required @@ -9642,9 +9645,9 @@ virDomainDiskIndexByName(virDomainDefPtr def, const char *name, const char * virDomainDiskPathByName(virDomainDefPtr def, const char *name) { - int i = virDomainDiskIndexByName(def, name, true); + int idx = virDomainDiskIndexByName(def, name, true); - return i < 0 ? NULL : def->disks[i]->src; + return idx < 0 ? NULL : def->disks[idx]->src; } int virDomainDiskInsert(virDomainDefPtr def, @@ -9662,7 +9665,7 @@ int virDomainDiskInsert(virDomainDefPtr def, void virDomainDiskInsertPreAlloced(virDomainDefPtr def, virDomainDiskDefPtr disk) { - int i; + int idx; /* Tenatively plan to insert disk at the end. */ int insertAt = -1; @@ -9671,19 +9674,19 @@ void virDomainDiskInsertPreAlloced(virDomainDefPtr def, * index greater than the new one, insert at * that position */ - for (i = (def->ndisks - 1); i >= 0; i--) { + for (idx = (def->ndisks - 1); idx >= 0; idx--) { /* If bus matches and current disk is after * new disk, then new disk should go here */ - if (def->disks[i]->bus == disk->bus && - (virDiskNameToIndex(def->disks[i]->dst) > + if (def->disks[idx]->bus == disk->bus && + (virDiskNameToIndex(def->disks[idx]->dst) > virDiskNameToIndex(disk->dst))) { - insertAt = i; - } else if (def->disks[i]->bus == disk->bus && + insertAt = idx; + } else if (def->disks[idx]->bus == disk->bus && insertAt == -1) { /* Last disk with match bus is before the * new disk, then put new disk just after */ - insertAt = i + 1; + insertAt = idx + 1; } } @@ -9725,10 +9728,10 @@ virDomainDiskRemove(virDomainDefPtr def, size_t i) virDomainDiskDefPtr virDomainDiskRemoveByName(virDomainDefPtr def, const char *name) { - int i = virDomainDiskIndexByName(def, name, false); - if (i < 0) + int idx = virDomainDiskIndexByName(def, name, false); + if (idx < 0) return NULL; - return virDomainDiskRemove(def, i); + return virDomainDiskRemove(def, idx); } /* Return true if VM has at least one disk involved in a current block @@ -9736,7 +9739,7 @@ virDomainDiskRemoveByName(virDomainDefPtr def, const char *name) bool virDomainHasDiskMirror(virDomainObjPtr vm) { - int i; + size_t i; for (i = 0; i < vm->def->ndisks; i++) if (vm->def->disks[i]->mirror) return true; @@ -9766,12 +9769,13 @@ int virDomainNetInsert(virDomainDefPtr def, virDomainNetDefPtr net) int virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) { - int ii, matchidx = -1; + size_t i; + int matchidx = -1; bool PCIAddrSpecified = virDomainDeviceAddressIsValid(&net->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI); - for (ii = 0; ii < def->nnets; ii++) { - if (virMacAddrCmp(&def->nets[ii]->mac, &net->mac)) + for (i = 0; i < def->nnets; i++) { + if (virMacAddrCmp(&def->nets[i]->mac, &net->mac)) continue; if ((matchidx >= 0) && !PCIAddrSpecified) { @@ -9785,17 +9789,17 @@ virDomainNetFindIdx(virDomainDefPtr def, virDomainNetDefPtr net) break; } if (PCIAddrSpecified) { - if (virDevicePCIAddressEqual(&def->nets[ii]->info.addr.pci, + if (virDevicePCIAddressEqual(&def->nets[i]->info.addr.pci, &net->info.addr.pci)) { /* exit early if the pci address was specified and * it matches, as this guarantees no duplicates. */ - matchidx = ii; + matchidx = i; break; } } else { /* no PCI address given, so there may be multiple matches */ - matchidx = ii; + matchidx = i; } } return matchidx; @@ -9851,7 +9855,7 @@ int virDomainControllerInsert(virDomainDefPtr def, void virDomainControllerInsertPreAlloced(virDomainDefPtr def, virDomainControllerDefPtr controller) { - int i; + int idx; /* Tenatively plan to insert controller at the end. */ int insertAt = -1; @@ -9860,18 +9864,18 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def, * index greater than the new one, insert at * that position */ - for (i = (def->ncontrollers - 1); i >= 0; i--) { + for (idx = (def->ncontrollers - 1); idx >= 0; idx--) { /* If bus matches and current controller is after * new controller, then new controller should go here */ - if (def->controllers[i]->type == controller->type && - def->controllers[i]->idx > controller->idx) { - insertAt = i; - } else if (def->controllers[i]->type == controller->type && + if (def->controllers[idx]->type == controller->type && + def->controllers[idx]->idx > controller->idx) { + insertAt = idx; + } else if (def->controllers[idx]->type == controller->type && insertAt == -1) { /* Last controller with match bus is before the * new controller, then put new controller just after */ - insertAt = i + 1; + insertAt = idx + 1; } } @@ -9892,7 +9896,7 @@ int virDomainControllerFind(virDomainDefPtr def, int type, int idx) { - int i; + size_t i; for (i = 0; i < def->ncontrollers; i++) { if ((def->controllers[i]->type == type) && @@ -9930,7 +9934,7 @@ int virDomainLeaseIndex(virDomainDefPtr def, virDomainLeaseDefPtr lease) { virDomainLeaseDefPtr vlease; - int i; + size_t i; for (i = 0; i < def->nleases; i++) { vlease = def->leases[i]; @@ -9998,10 +10002,10 @@ virDomainLeaseDefPtr virDomainLeaseRemove(virDomainDefPtr def, virDomainLeaseDefPtr lease) { - int i = virDomainLeaseIndex(def, lease); - if (i < 0) + int idx = virDomainLeaseIndex(def, lease); + if (idx < 0) return NULL; - return virDomainLeaseRemoveAt(def, i); + return virDomainLeaseRemoveAt(def, idx); } @@ -10042,7 +10046,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, virDomainDefPtr def) { xmlNodePtr *nodes = NULL; - int i, n; + size_t i; + int n; char *tmp = NULL; int ret = -1; unsigned long deviceBoot, serialPorts; @@ -10288,7 +10293,7 @@ virDomainVcpuPinDefPtr virDomainLookupVcpuPin(virDomainDefPtr def, int vcpuid) { - int i; + size_t i; if (!def->cputune.vcpupin) return NULL; @@ -10307,7 +10312,7 @@ virDomainDefMaybeAddController(virDomainDefPtr def, int idx, int model) { - int i; + size_t i; virDomainControllerDefPtr cont; for (i = 0; i < def->ncontrollers; i++) { @@ -10399,7 +10404,7 @@ static int virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def) { /* Look for any hostdev scsi dev */ - int i; + size_t i; int maxController = -1; virDomainHostdevDefPtr hostdev; @@ -10412,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; @@ -10431,7 +10439,8 @@ virDomainDefParseXML(xmlDocPtr xml, { xmlNodePtr *nodes = NULL, node = NULL; char *tmp = NULL; - int i, n; + size_t i; + int n; long id = -1; virDomainDefPtr def; unsigned long count; @@ -10607,7 +10616,7 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; for (i = 0; i < n; i++) { - int j; + size_t j; if (virDomainBlkioDeviceWeightParseXML(nodes[i], &def->blkio.devices[i]) < 0) goto error; @@ -11558,7 +11567,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (chr->target.port == -1) { int maxport = -1; - int j; + size_t j; for (j = 0; j < i; j++) { if (def->parallels[j]->target.port > maxport) maxport = def->parallels[j]->target.port; @@ -11586,7 +11595,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (chr->target.port == -1) { int maxport = -1; - int j; + size_t j; for (j = 0; j < i; j++) { if (def->serials[j]->target.port > maxport) maxport = def->serials[j]->target.port; @@ -11644,7 +11653,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (chr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL && chr->info.addr.vioserial.port == 0) { int maxport = 0; - int j; + size_t j; for (j = 0; j < i; j++) { virDomainChrDefPtr thischr = def->channels[j]; if (thischr->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL && @@ -11764,8 +11773,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (n && VIR_ALLOC_N(def->videos, n) < 0) goto error; for (i = 0; i < n; i++) { - size_t ii = def->nvideos; - virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[i], + size_t j = def->nvideos; + virDomainVideoDefPtr video = virDomainVideoDefParseXML(nodes[j], def, flags); if (!video) @@ -11779,11 +11788,11 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } - ii = 0; + j = 0; primaryVideo = true; } if (VIR_INSERT_ELEMENT_INPLACE(def->videos, - ii, + j, def->nvideos, video) < 0) { virDomainVideoDefFree(video); @@ -12142,7 +12151,8 @@ virDomainObjParseXML(xmlDocPtr xml, xmlNodePtr oldnode; virDomainObjPtr obj; xmlNodePtr *nodes = NULL; - int i, n; + size_t i; + int n; int state; int reason = 0; @@ -12969,7 +12979,7 @@ static bool virDomainRedirFilterDefCheckABIStability(virDomainRedirFilterDefPtr src, virDomainRedirFilterDefPtr dst) { - int i; + size_t i; if (src->nusbdevs != dst->nusbdevs) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -13026,7 +13036,7 @@ bool virDomainDefCheckABIStability(virDomainDefPtr src, virDomainDefPtr dst) { - int i; + size_t i; if (src->virtType != dst->virtType) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -13371,7 +13381,7 @@ virDomainDefAddDiskControllersForType(virDomainDefPtr def, int controllerType, int diskBus) { - int i; + size_t i; int maxController = -1; for (i = 0; i < def->ndisks; i++) { @@ -13385,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; @@ -13398,7 +13411,7 @@ static int virDomainDefMaybeAddVirtioSerialController(virDomainDefPtr def) { /* Look for any virtio serial or virtio console devs */ - int i; + size_t i; for (i = 0; i < def->nchannels; i++) { virDomainChrDefPtr channel = def->channels[i]; @@ -13437,7 +13450,7 @@ static int virDomainDefMaybeAddSmartcardController(virDomainDefPtr def) { /* Look for any smartcard devs */ - int i; + size_t i; for (i = 0; i < def->nsmartcards; i++) { virDomainSmartcardDefPtr smartcard = def->smartcards[i]; @@ -13447,7 +13460,7 @@ virDomainDefMaybeAddSmartcardController(virDomainDefPtr def) idx = smartcard->info.addr.ccid.controller; } else if (smartcard->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { - int j; + size_t j; int max = -1; for (j = 0; j < def->nsmartcards; j++) { @@ -13519,7 +13532,7 @@ virDomainVcpuPinIsDuplicate(virDomainVcpuPinDefPtr *def, int nvcpupin, int vcpu) { - int i; + size_t i; if (!def || !nvcpupin) return 0; @@ -13537,7 +13550,7 @@ virDomainVcpuPinFindByVcpu(virDomainVcpuPinDefPtr *def, int nvcpupin, int vcpu) { - int i; + size_t i; if (!def || !nvcpupin) return NULL; @@ -13883,7 +13896,7 @@ virDomainDiskSourceDefFormat(virBufferPtr buf, if (def->nhosts == 0) { virBufferAddLit(buf, "/>\n"); } else { - int i; + size_t i; virBufferAddLit(buf, ">\n"); for (i = 0; i < def->nhosts; i++) { @@ -14237,7 +14250,7 @@ int virDomainFSIndexByName(virDomainDefPtr def, const char *name) { virDomainFSDefPtr fs; - int i; + size_t i; for (i = 0; i < def->nfss; i++) { fs = def->fss[i]; @@ -15024,7 +15037,7 @@ virDomainSoundDefFormat(virBufferPtr buf, { const char *model = virDomainSoundModelTypeToString(def->model); bool children = false; - int i; + size_t i; if (!model) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -15460,7 +15473,7 @@ virDomainGraphicsDefFormat(virBufferPtr buf, const char *type = virDomainGraphicsTypeToString(def->type); const char *listenAddr = NULL; bool children = false; - int i; + size_t i; if (!type) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -15830,7 +15843,7 @@ virDomainHubDefFormat(virBufferPtr buf, static bool virDomainIsAllVcpupinInherited(virDomainDefPtr def) { - int i; + size_t i; if (!def->cpumask) { if (def->cputune.nvcpupin) @@ -15884,7 +15897,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, char uuidstr[VIR_UUID_STRING_BUFLEN]; const char *type = NULL; int n; - int i; + size_t i; bool blkio = false; virCheckFlags(DUMPXML_FLAGS | @@ -16259,7 +16272,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, const char *name = virDomainFeatureTypeToString(i); if (!name) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected feature %d"), i); + _("unexpected feature %zu"), i); goto error; } virBufferAsprintf(buf, " <%s", name); @@ -16562,7 +16575,7 @@ virDomainObjFormat(virDomainXMLOptionPtr xmlopt, virBuffer buf = VIR_BUFFER_INITIALIZER; int state; int reason; - int i; + size_t i; state = virDomainObjGetState(obj, &reason); virBufferAsprintf(&buf, "\n", @@ -16602,7 +16615,7 @@ error: static bool virDomainDefHasUSB(virDomainDefPtr def) { - int i; + size_t i; for (i = 0; i < def->ncontrollers; i++) { if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && @@ -16979,7 +16992,7 @@ virDiskNameToBusDeviceIndex(const virDomainDiskDefPtr disk, virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def) { - int i; + size_t i; for (i = 0; i < def->nfss; i++) { if (STREQ(def->fss[i]->dst, "/")) @@ -17116,7 +17129,7 @@ virDomainObjListGetInactiveNames(virDomainObjListPtr doms, { struct virDomainNameData data = { filter, conn, 0, 0, maxnames, names }; - int i; + size_t i; virObjectLock(doms); virHashForEach(doms->objs, virDomainObjListCopyInactiveNames, &data); virObjectUnlock(doms); @@ -17168,7 +17181,7 @@ virDomainChrDefForeach(virDomainDefPtr def, virDomainChrDefIterator iter, void *opaque) { - int i; + size_t i; int rc = 0; for (i = 0; i < def->nserials; i++) { @@ -17221,7 +17234,7 @@ virDomainSmartcardDefForeach(virDomainDefPtr def, virDomainSmartcardDefIterator iter, void *opaque) { - int i; + size_t i; int rc = 0; for (i = 0; i < def->nsmartcards; i++) { @@ -17546,26 +17559,26 @@ virDomainNetGetActualVlan(virDomainNetDefPtr iface) return 0; } -/* Return listens[ii] from the appropriate union for the graphics +/* Return listens[i] from the appropriate union for the graphics * type, or NULL if this is an unsuitable type, or the index is out of - * bounds. If force0 is TRUE, ii == 0, and there is no listen array, + * bounds. If force0 is TRUE, i == 0, and there is no listen array, * allocate one with a single item. */ static virDomainGraphicsListenDefPtr -virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t ii, bool force0) +virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i, bool force0) { if (def->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC || def->type == VIR_DOMAIN_GRAPHICS_TYPE_RDP || def->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { - if (!def->listens && (ii == 0) && force0) { + if (!def->listens && (i == 0) && force0) { if (VIR_ALLOC(def->listens) >= 0) def->nListens = 1; } - if (!def->listens || (def->nListens <= ii)) + if (!def->listens || (def->nListens <= i)) return NULL; - return &def->listens[ii]; + return &def->listens[i]; } /* it's a type that has no listens array */ @@ -17587,10 +17600,10 @@ virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t ii, bool force0) * return 0 on success, -1 on failure. */ int -virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t ii) +virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, false); + = virDomainGraphicsGetListen(def, i, false); if (!listenInfo) return VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE; @@ -17602,10 +17615,10 @@ virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t ii) * *will not* free any existing address or network based on a change * in value of type. */ int -virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t ii, int val) +virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int val) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, true); + = virDomainGraphicsGetListen(def, i, true); if (!listenInfo) return -1; @@ -17615,10 +17628,10 @@ virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t ii, int val) const char * -virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t ii) +virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t i) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, false); + = virDomainGraphicsGetListen(def, i, false); /* even a network can have a listen address */ if (!listenInfo || @@ -17630,15 +17643,15 @@ virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, size_t ii) /* Make a copy of up to len characters of address, and store it in - * listens[ii].address. If setType is true, set the listen's type + * listens[i].address. If setType is true, set the listen's type * to 'address', otherwise leave type alone. */ int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def, - size_t ii, const char *address, + size_t i, const char *address, int len, bool setType) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, true); + = virDomainGraphicsGetListen(def, i, true); if (!listenInfo) return -1; @@ -17658,10 +17671,10 @@ virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def, const char * -virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t ii) +virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t i) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, false); + = virDomainGraphicsGetListen(def, i, false); if (!listenInfo || (listenInfo->type != VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) @@ -17671,13 +17684,13 @@ virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, size_t ii) /* Make a copy of up to len characters of address, and store it in - * listens[ii].network */ + * listens[i].network */ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def, - size_t ii, const char *network, int len) + size_t i, const char *network, int len) { virDomainGraphicsListenDefPtr listenInfo - = virDomainGraphicsGetListen(def, ii, true); + = virDomainGraphicsGetListen(def, i, true); if (!listenInfo) return -1; @@ -17709,7 +17722,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device) bool isMac = false; virDomainNetDefPtr net = NULL; virMacAddr mac; - int i; + size_t i; if (virMacAddrParse(device, &mac) == 0) isMac = true; @@ -17939,7 +17952,7 @@ virDomainObjListExport(virDomainObjListPtr doms, unsigned int flags) { int ret = -1; - int i; + size_t i; struct virDomainListData data = { conn, NULL, @@ -17981,7 +17994,7 @@ cleanup: virSecurityLabelDefPtr virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model) { - int i; + size_t i; virSecurityLabelDefPtr seclabel = NULL; if (def == NULL || model == NULL) @@ -18000,7 +18013,7 @@ virDomainDefGetSecurityLabelDef(virDomainDefPtr def, const char *model) virSecurityDeviceLabelDefPtr virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model) { - int i; + size_t i; if (def == NULL) return NULL; @@ -18015,7 +18028,7 @@ virDomainDiskDefGetSecurityLabelDef(virDomainDiskDefPtr def, const char *model) virSecurityDeviceLabelDefPtr virDomainChrDefGetSecurityLabelDef(virDomainChrDefPtr def, const char *model) { - int i; + size_t i; if (def == NULL) return NULL; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index da83eb60607a19075a6b4951933e5e23845f0aba..4a7dcd2f1edd9ca915c38c6dc91309b8f6294268 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2342,22 +2342,22 @@ virDomainHostdevRemove(virDomainDefPtr def, size_t i); int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match, virDomainHostdevDefPtr *found); -int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t ii) +int virDomainGraphicsListenGetType(virDomainGraphicsDefPtr def, size_t i) ATTRIBUTE_NONNULL(1); -int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t ii, int val) +int virDomainGraphicsListenSetType(virDomainGraphicsDefPtr def, size_t i, int val) ATTRIBUTE_NONNULL(1); const char *virDomainGraphicsListenGetAddress(virDomainGraphicsDefPtr def, - size_t ii) + size_t i) ATTRIBUTE_NONNULL(1); int virDomainGraphicsListenSetAddress(virDomainGraphicsDefPtr def, - size_t ii, const char *address, + size_t i, const char *address, int len, bool setType) ATTRIBUTE_NONNULL(1); const char *virDomainGraphicsListenGetNetwork(virDomainGraphicsDefPtr def, - size_t ii) + size_t i) ATTRIBUTE_NONNULL(1); int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def, - size_t ii, const char *network, int len) + size_t i, const char *network, int len) ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c index 260e5544fdaa5e832023981e3551a0c58a54655e..fde24be6772f0bde7d9b5c70dfa0678d511d484a 100644 --- a/src/conf/domain_event.c +++ b/src/conf/domain_event.c @@ -134,7 +134,7 @@ struct _virDomainEvent { static void virDomainEventCallbackListFree(virDomainEventCallbackListPtr list) { - int i; + size_t i; if (!list) return; @@ -162,7 +162,7 @@ virDomainEventCallbackListRemove(virConnectPtr conn, virConnectDomainEventCallback callback) { int ret = 0; - int i; + size_t i; for (i = 0; i < cbList->count; i++) { if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) && cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE && @@ -213,7 +213,7 @@ virDomainEventCallbackListRemoveID(virConnectPtr conn, int callbackID) { int ret = 0; - int i; + size_t i; for (i = 0; i < cbList->count; i++) { if (cbList->callbacks[i]->callbackID == callbackID && cbList->callbacks[i]->conn == conn) { @@ -255,7 +255,7 @@ virDomainEventCallbackListMarkDelete(virConnectPtr conn, virConnectDomainEventCallback callback) { int ret = 0; - int i; + size_t i; for (i = 0; i < cbList->count; i++) { if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) && cbList->callbacks[i]->eventID == VIR_DOMAIN_EVENT_ID_LIFECYCLE && @@ -281,7 +281,7 @@ virDomainEventCallbackListMarkDeleteID(virConnectPtr conn, int callbackID) { int ret = 0; - int i; + size_t i; for (i = 0; i < cbList->count; i++) { if (cbList->callbacks[i]->callbackID == callbackID && cbList->callbacks[i]->conn == conn) { @@ -304,22 +304,22 @@ static int virDomainEventCallbackListPurgeMarked(virDomainEventCallbackListPtr cbList) { int old_count = cbList->count; - int 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 && @@ -352,7 +352,7 @@ virDomainEventCallbackListAddID(virConnectPtr conn, int *callbackID) { virDomainEventCallbackPtr event; - int i; + size_t i; int ret = 0; /* Check incoming */ @@ -455,7 +455,7 @@ virDomainEventCallbackListEventID(virConnectPtr conn, virDomainEventCallbackListPtr cbList, int callbackID) { - int i; + size_t i; for (i = 0; i < cbList->count; i++) { if (cbList->callbacks[i]->deleted) @@ -496,7 +496,7 @@ void virDomainEventFree(virDomainEventPtr event) } VIR_FREE(event->data.graphics.authScheme); if (event->data.graphics.subject) { - int i; + size_t i; for (i = 0; i < event->data.graphics.subject->nidentity; i++) { VIR_FREE(event->data.graphics.subject->identities[i].type); VIR_FREE(event->data.graphics.subject->identities[i].name); @@ -532,7 +532,7 @@ void virDomainEventFree(virDomainEventPtr event) static void virDomainEventQueueClear(virDomainEventQueuePtr queue) { - int i; + size_t i; if (!queue) return; @@ -1345,7 +1345,7 @@ virDomainEventDispatch(virDomainEventPtr event, virDomainEventDispatchFunc dispatch, void *opaque) { - int i; + size_t i; /* Cache this now, since we may be dropping the lock, and have more callbacks added. We're guaranteed not to have any removed */ @@ -1370,7 +1370,7 @@ virDomainEventQueueDispatch(virDomainEventQueuePtr queue, virDomainEventDispatchFunc dispatch, void *opaque) { - int i; + size_t i; for (i = 0; i < queue->count; i++) { virDomainEventDispatch(queue->events[i], callbacks, dispatch, opaque); diff --git a/src/conf/domain_nwfilter.c b/src/conf/domain_nwfilter.c index f42905e0e40874b9941195366abaab9c261e3c15..688a200f34f04bfcf6e489fc03d301afbc02ca27 100644 --- a/src/conf/domain_nwfilter.c +++ b/src/conf/domain_nwfilter.c @@ -53,7 +53,7 @@ virDomainConfNWFilterTeardown(virDomainNetDefPtr net) { void virDomainConfVMNWFilterTeardown(virDomainObjPtr vm) { - int i; + size_t i; if (nwfilterDriver != NULL) { for (i = 0; i < vm->def->nnets; i++) diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 7725b3904489db2cb9aca9f776c58304907bcc03..19d03270ef8d3071c54090d0306ad6fb29960392 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -54,12 +54,12 @@ void virInterfaceIpDefFree(virInterfaceIpDefPtr def) { static void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) { - int ii; + size_t i; if (def == NULL) return; - for (ii = 0; ii < def->nips; ii++) { - virInterfaceIpDefFree(def->ips[ii]); + for (i = 0; i < def->nips; i++) { + virInterfaceIpDefFree(def->ips[i]); } VIR_FREE(def->ips); VIR_FREE(def->family); @@ -69,7 +69,8 @@ void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) { void virInterfaceDefFree(virInterfaceDefPtr def) { - int i, pp; + size_t i; + int pp; if (def == NULL) return; @@ -299,7 +300,8 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr dhcp; xmlNodePtr *ipNodes = NULL; - int nIpNodes, ii, ret = -1; + int nIpNodes, ret = -1; + size_t i; char *tmp; tmp = virXPathString("string(./route[1]/@gateway)", ctxt); @@ -322,14 +324,14 @@ virInterfaceDefParseProtoIPv4(virInterfaceProtocolDefPtr def, goto error; def->nips = 0; - for (ii = 0; ii < nIpNodes; ii++) { + for (i = 0; i < nIpNodes; i++) { virInterfaceIpDefPtr ip; if (VIR_ALLOC(ip) < 0) goto error; - ctxt->node = ipNodes[ii]; + ctxt->node = ipNodes[i]; ret = virInterfaceDefParseIp(ip, ctxt); if (ret != 0) { virInterfaceIpDefFree(ip); @@ -350,7 +352,8 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def, xmlXPathContextPtr ctxt) { xmlNodePtr dhcp, autoconf; xmlNodePtr *ipNodes = NULL; - int nIpNodes, ii, ret = -1; + int nIpNodes, ret = -1; + size_t i; char *tmp; tmp = virXPathString("string(./route[1]/@gateway)", ctxt); @@ -377,14 +380,14 @@ virInterfaceDefParseProtoIPv6(virInterfaceProtocolDefPtr def, goto error; def->nips = 0; - for (ii = 0; ii < nIpNodes; ii++) { + for (i = 0; i < nIpNodes; i++) { virInterfaceIpDefPtr ip; if (VIR_ALLOC(ip) < 0) goto error; - ctxt->node = ipNodes[ii]; + ctxt->node = ipNodes[i]; ret = virInterfaceDefParseIp(ip, ctxt); if (ret != 0) { virInterfaceIpDefFree(ip); @@ -475,7 +478,8 @@ virInterfaceDefParseBridge(virInterfaceDefPtr def, xmlNodePtr *interfaces = NULL; xmlNodePtr bridge; virInterfaceDefPtr itf; - int nbItf, i; + int nbItf; + size_t i; int ret = 0; bridge = ctxt->node; @@ -515,7 +519,8 @@ virInterfaceDefParseBondItfs(virInterfaceDefPtr def, xmlNodePtr *interfaces = NULL; xmlNodePtr bond = ctxt->node; virInterfaceDefPtr itf; - int nbItf, i; + int nbItf; + size_t i; int ret = 0; nbItf = virXPathNodeSet("./interface", ctxt, &interfaces); @@ -858,7 +863,7 @@ virInterfaceDefPtr virInterfaceDefParseFile(const char *filename) static int virInterfaceBridgeDefFormat(virBufferPtr buf, const virInterfaceDefPtr def, int level) { - int i; + size_t i; int ret = 0; virBufferAsprintf(buf, "%*s nprotos; pp++) { + for (i = 0; i < def->nprotos; i++) { virBufferAsprintf(buf, "%*s \n", - level*2, "", def->protos[pp]->family); + level*2, "", def->protos[i]->family); - if (def->protos[pp]->autoconf) { + if (def->protos[i]->autoconf) { virBufferAsprintf(buf, "%*s \n", level*2, ""); } - if (def->protos[pp]->dhcp) { - if (def->protos[pp]->peerdns == 0) + if (def->protos[i]->dhcp) { + if (def->protos[i]->peerdns == 0) virBufferAsprintf(buf, "%*s \n", level*2, ""); - else if (def->protos[pp]->peerdns == 1) + else if (def->protos[i]->peerdns == 1) virBufferAsprintf(buf, "%*s \n", level*2, ""); else virBufferAsprintf(buf, "%*s \n", level*2, ""); } - for (ii = 0; ii < def->protos[pp]->nips; ii++) { - if (def->protos[pp]->ips[ii]->address != NULL) { + for (j = 0; j < def->protos[i]->nips; j++) { + if (def->protos[i]->ips[j]->address != NULL) { virBufferAsprintf(buf, "%*s protos[pp]->ips[ii]->address); - if (def->protos[pp]->ips[ii]->prefix != 0) { + def->protos[i]->ips[j]->address); + if (def->protos[i]->ips[j]->prefix != 0) { virBufferAsprintf(buf, " prefix='%d'", - def->protos[pp]->ips[ii]->prefix); + def->protos[i]->ips[j]->prefix); } virBufferAddLit(buf, "/>\n"); } } - if (def->protos[pp]->gateway != NULL) { + if (def->protos[i]->gateway != NULL) { virBufferAsprintf(buf, "%*s \n", - level*2, "", def->protos[pp]->gateway); + level*2, "", def->protos[i]->gateway); } virBufferAsprintf(buf, "%*s \n", level*2, ""); @@ -1153,7 +1158,8 @@ int virInterfaceFindByMACString(const virInterfaceObjListPtr interfaces, const char *mac, virInterfaceObjPtr *matches, int maxmatches) { - unsigned int i, matchct = 0; + size_t i; + unsigned int matchct = 0; for (i = 0; i < interfaces->count; i++) { @@ -1177,7 +1183,7 @@ virInterfaceObjPtr virInterfaceFindByName(const virInterfaceObjListPtr interfaces, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < interfaces->count; i++) { virInterfaceObjLock(interfaces->objs[i]); @@ -1191,7 +1197,7 @@ virInterfaceObjPtr virInterfaceFindByName(const virInterfaceObjListPtr void virInterfaceObjListFree(virInterfaceObjListPtr interfaces) { - unsigned int i; + size_t i; for (i = 0; i < interfaces->count; i++) virInterfaceObjFree(interfaces->objs[i]); @@ -1204,7 +1210,8 @@ int virInterfaceObjListClone(virInterfaceObjListPtr src, virInterfaceObjListPtr dest) { int ret = -1; - unsigned int i, cnt; + size_t i; + unsigned int cnt; if (!src || !dest) goto cleanup; @@ -1276,7 +1283,7 @@ virInterfaceObjPtr virInterfaceAssignDef(virInterfaceObjListPtr interfaces, void virInterfaceRemove(virInterfaceObjListPtr interfaces, const virInterfaceObjPtr iface) { - unsigned int i; + size_t i; virInterfaceObjUnlock(iface); for (i = 0; i < interfaces->count; i++) { diff --git a/src/conf/netdev_vlan_conf.c b/src/conf/netdev_vlan_conf.c index 54fb0fdebbdd5eeaa88593bcc7d44ad8724abca0..60d9eb83520bf9c1b4a98b3b409cb36540041436 100644 --- a/src/conf/netdev_vlan_conf.c +++ b/src/conf/netdev_vlan_conf.c @@ -39,7 +39,8 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr de const char *trunk = NULL; const char *nativeMode = NULL; xmlNodePtr *tagNodes = NULL; - int nTags, ii; + int nTags; + size_t i; ctxt->node = node; @@ -59,10 +60,10 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr de def->nativeMode = 0; def->nativeTag = 0; - for (ii = 0; ii < nTags; ii++) { + for (i = 0; i < nTags; i++) { unsigned long id; - ctxt->node = tagNodes[ii]; + ctxt->node = tagNodes[i]; if (virXPathULong("string(./@id)", ctxt, &id) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing or invalid vlan tag id attribute")); @@ -90,7 +91,7 @@ virNetDevVlanParse(xmlNodePtr node, xmlXPathContextPtr ctxt, virNetDevVlanPtr de VIR_FREE(nativeMode); def->nativeTag = id; } - def->tag[ii] = id; + def->tag[i] = id; } def->nTags = nTags; @@ -141,7 +142,7 @@ cleanup: int virNetDevVlanFormat(virNetDevVlanPtr def, virBufferPtr buf) { - int ii; + size_t i; if (def->nTags == 0) return 0; @@ -153,9 +154,9 @@ virNetDevVlanFormat(virNetDevVlanPtr def, virBufferPtr buf) } virBufferAsprintf(buf, "\n", def->trunk ? " trunk='yes'" : ""); - for (ii = 0; ii < def->nTags; ii++) { + for (i = 0; i < def->nTags; i++) { if (def->nativeMode != VIR_NATIVE_VLAN_MODE_DEFAULT && - def->nativeTag == def->tag[ii]) { + def->nativeTag == def->tag[i]) { /* check the nativeMode in case we get */ const char *mode = virNativeVlanModeTypeToString(def->nativeMode); if (!mode) { @@ -163,9 +164,9 @@ virNetDevVlanFormat(virNetDevVlanPtr def, virBufferPtr buf) _("Bad value for nativeMode")); } virBufferAsprintf(buf, " \n", - def->tag[ii], mode); + def->tag[i], mode); } else { - virBufferAsprintf(buf, " \n", def->tag[ii]); + virBufferAsprintf(buf, " \n", def->tag[i]); } } virBufferAddLit(buf, "\n"); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index bfc041eb786ea2cbe0e5a8687412e361b3b09f4d..d616e12c7cc496c2bbb852a805228ffba1277921 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -69,7 +69,7 @@ VIR_ENUM_IMPL(virNetworkForwardDriverName, virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets, const unsigned char *uuid) { - unsigned int i; + size_t i; for (i = 0; i < nets->count; i++) { virNetworkObjLock(nets->objs[i]); @@ -84,7 +84,7 @@ virNetworkObjPtr virNetworkFindByUUID(const virNetworkObjListPtr nets, virNetworkObjPtr virNetworkFindByName(const virNetworkObjListPtr nets, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < nets->count; i++) { virNetworkObjLock(nets->objs[i]); @@ -195,15 +195,15 @@ virNetworkDNSDefClear(virNetworkDNSDefPtr def) static void virNetworkForwardDefClear(virNetworkForwardDefPtr def) { - int ii; + size_t i; - for (ii = 0; ii < def->npfs && def->pfs; ii++) { - virNetworkForwardPfDefClear(&def->pfs[ii]); + for (i = 0; i < def->npfs && def->pfs; i++) { + virNetworkForwardPfDefClear(&def->pfs[i]); } VIR_FREE(def->pfs); - for (ii = 0; ii < def->nifs && def->ifs; ii++) { - virNetworkForwardIfDefClear(&def->ifs[ii]); + for (i = 0; i < def->nifs && def->ifs; i++) { + virNetworkForwardIfDefClear(&def->ifs[i]); } VIR_FREE(def->ifs); } @@ -211,7 +211,7 @@ virNetworkForwardDefClear(virNetworkForwardDefPtr def) void virNetworkDefFree(virNetworkDefPtr def) { - int ii; + size_t i; if (!def) return; @@ -222,18 +222,18 @@ virNetworkDefFree(virNetworkDefPtr def) virNetworkForwardDefClear(&def->forward); - for (ii = 0; ii < def->nips && def->ips; ii++) { - virNetworkIpDefClear(&def->ips[ii]); + for (i = 0; i < def->nips && def->ips; i++) { + virNetworkIpDefClear(&def->ips[i]); } VIR_FREE(def->ips); - for (ii = 0; ii < def->nroutes && def->routes; ii++) { - virNetworkRouteDefClear(&def->routes[ii]); + for (i = 0; i < def->nroutes && def->routes; i++) { + virNetworkRouteDefClear(&def->routes[i]); } VIR_FREE(def->routes); - for (ii = 0; ii < def->nPortGroups && def->portGroups; ii++) { - virPortGroupDefClear(&def->portGroups[ii]); + for (i = 0; i < def->nPortGroups && def->portGroups; i++) { + virPortGroupDefClear(&def->portGroups[i]); } VIR_FREE(def->portGroups); @@ -262,7 +262,7 @@ void virNetworkObjFree(virNetworkObjPtr net) void virNetworkObjListFree(virNetworkObjListPtr nets) { - unsigned int i; + size_t i; for (i = 0; i < nets->count; i++) virNetworkObjFree(nets->objs[i]); @@ -539,7 +539,7 @@ cleanup: void virNetworkRemoveInactive(virNetworkObjListPtr nets, const virNetworkObjPtr net) { - unsigned int i; + size_t i; virNetworkObjUnlock(net); for (i = 0; i < nets->count; i++) { @@ -568,7 +568,7 @@ virNetworkIpDefPtr virNetworkDefGetIpByIndex(const virNetworkDefPtr def, int family, size_t n) { - int ii; + size_t i; if (!def->ips || n >= def->nips) return NULL; @@ -578,10 +578,10 @@ virNetworkDefGetIpByIndex(const virNetworkDefPtr def, } /* find the nth ip of type "family" */ - for (ii = 0; ii < def->nips; ii++) { - if (VIR_SOCKET_ADDR_IS_FAMILY(&def->ips[ii].address, family) + for (i = 0; i < def->nips; i++) { + if (VIR_SOCKET_ADDR_IS_FAMILY(&def->ips[i].address, family) && (n-- <= 0)) { - return &def->ips[ii]; + return &def->ips[i]; } } /* failed to find enough of the right family */ @@ -1037,7 +1037,8 @@ virNetworkDNSDefParseXML(const char *networkName, xmlNodePtr *srvNodes = NULL; xmlNodePtr *txtNodes = NULL; int nhosts, nsrvs, ntxts; - int ii, ret = -1; + size_t i; + int ret = -1; xmlNodePtr save = ctxt->node; ctxt->node = node; @@ -1053,8 +1054,8 @@ virNetworkDNSDefParseXML(const char *networkName, if (VIR_ALLOC_N(def->hosts, nhosts) < 0) goto cleanup; - for (ii = 0; ii < nhosts; ii++) { - if (virNetworkDNSHostDefParseXML(networkName, hostNodes[ii], + for (i = 0; i < nhosts; i++) { + if (virNetworkDNSHostDefParseXML(networkName, hostNodes[i], &def->hosts[def->nhosts], false) < 0) { goto cleanup; } @@ -1073,8 +1074,8 @@ virNetworkDNSDefParseXML(const char *networkName, if (VIR_ALLOC_N(def->srvs, nsrvs) < 0) goto cleanup; - for (ii = 0; ii < nsrvs; ii++) { - if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[ii], ctxt, + for (i = 0; i < nsrvs; i++) { + if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[i], ctxt, &def->srvs[def->nsrvs], false) < 0) { goto cleanup; } @@ -1093,8 +1094,8 @@ virNetworkDNSDefParseXML(const char *networkName, if (VIR_ALLOC_N(def->txts, ntxts) < 0) goto cleanup; - for (ii = 0; ii < ntxts; ii++) { - if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[ii], + for (i = 0; i < ntxts; i++) { + if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[i], &def->txts[def->ntxts], false) < 0) { goto cleanup; } @@ -1661,7 +1662,8 @@ virNetworkForwardDefParseXML(const char *networkName, xmlXPathContextPtr ctxt, virNetworkForwardDefPtr def) { - int ii, ret = -1; + size_t i; + int ret = -1; xmlNodePtr *forwardIfNodes = NULL; xmlNodePtr *forwardPfNodes = NULL; xmlNodePtr *forwardAddrNodes = NULL; @@ -1779,8 +1781,8 @@ virNetworkForwardDefParseXML(const char *networkName, } /* parse each */ - for (ii = 0; ii < nForwardIfs; ii++) { - forwardDev = virXMLPropString(forwardIfNodes[ii], "dev"); + for (i = 0; i < nForwardIfs; i++) { + forwardDev = virXMLPropString(forwardIfNodes[i], "dev"); if (!forwardDev) { virReportError(VIR_ERR_XML_ERROR, _("Missing required dev attribute in " @@ -1789,7 +1791,7 @@ virNetworkForwardDefParseXML(const char *networkName, goto cleanup; } - if ((ii == 0) && (def->nifs == 1)) { + if ((i == 0) && (def->nifs == 1)) { /* both and are * present. If they don't match, it's an error. */ @@ -1805,9 +1807,9 @@ virNetworkForwardDefParseXML(const char *networkName, continue; } - def->ifs[ii].device.dev = forwardDev; + def->ifs[i].device.dev = forwardDev; forwardDev = NULL; - def->ifs[ii].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV; + def->ifs[i].type = VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV; def->nifs++; } @@ -1815,25 +1817,25 @@ virNetworkForwardDefParseXML(const char *networkName, if (VIR_ALLOC_N(def->ifs, nForwardAddrs) < 0) goto cleanup; - for (ii = 0; ii < nForwardAddrs; ii++) { - if (!(type = virXMLPropString(forwardAddrNodes[ii], "type"))) { + for (i = 0; i < nForwardAddrs; i++) { + if (!(type = virXMLPropString(forwardAddrNodes[i], "type"))) { virReportError(VIR_ERR_XML_ERROR, _("missing address type in network %s"), networkName); goto cleanup; } - if ((def->ifs[ii].type = virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) { + if ((def->ifs[i].type = virNetworkForwardHostdevDeviceTypeFromString(type)) < 0) { virReportError(VIR_ERR_XML_ERROR, _("unknown address type '%s' in network %s"), type, networkName); goto cleanup; } - switch (def->ifs[ii].type) { + switch (def->ifs[i].type) { case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI: - if (virDevicePCIAddressParseXML(forwardAddrNodes[ii], - &def->ifs[ii].device.pci) < 0) { + if (virDevicePCIAddressParseXML(forwardAddrNodes[i], + &def->ifs[i].device.pci) < 0) { goto cleanup; } break; @@ -2007,15 +2009,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) goto error; if (nPortGroups > 0) { - int ii; + size_t i; /* allocate array to hold all the portgroups */ if (VIR_ALLOC_N(def->portGroups, nPortGroups) < 0) goto error; /* parse each portgroup */ - for (ii = 0; ii < nPortGroups; ii++) { - int ret = virNetworkPortGroupParseXML(&def->portGroups[ii], - portGroupNodes[ii], ctxt); + for (i = 0; i < nPortGroups; i++) { + int ret = virNetworkPortGroupParseXML(&def->portGroups[i], + portGroupNodes[i], ctxt); if (ret < 0) goto error; def->nPortGroups++; @@ -2028,15 +2030,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) goto error; if (nIps > 0) { - int ii; + size_t i; /* allocate array to hold all the addrs */ if (VIR_ALLOC_N(def->ips, nIps) < 0) goto error; /* parse each addr */ - for (ii = 0; ii < nIps; ii++) { - int ret = virNetworkIPDefParseXML(def->name, ipNodes[ii], - ctxt, &def->ips[ii]); + for (i = 0; i < nIps; i++) { + int ret = virNetworkIPDefParseXML(def->name, ipNodes[i], + ctxt, &def->ips[i]); if (ret < 0) goto error; def->nips++; @@ -2049,15 +2051,15 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) goto error; if (nRoutes > 0) { - int ii; + size_t i; /* allocate array to hold all the route definitions */ if (VIR_ALLOC_N(def->routes, nRoutes) < 0) goto error; /* parse each definition */ - for (ii = 0; ii < nRoutes; ii++) { - int ret = virNetworkRouteDefParseXML(def->name, routeNodes[ii], - ctxt, &def->routes[ii]); + for (i = 0; i < nRoutes; i++) { + int ret = virNetworkRouteDefParseXML(def->name, routeNodes[i], + ctxt, &def->routes[i]); if (ret < 0) goto error; def->nroutes++; @@ -2071,14 +2073,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) */ nRoutes = def->nroutes; nIps = def->nips; - for (ii = 0; ii < nRoutes; ii++) { - int jj; + for (i = 0; i < nRoutes; i++) { + size_t j; virSocketAddr testAddr, testGw; bool addrMatch; - virNetworkRouteDefPtr gwdef = &def->routes[ii]; + virNetworkRouteDefPtr gwdef = &def->routes[i]; addrMatch = false; - for (jj = 0; jj < nIps; jj++) { - virNetworkIpDefPtr def2 = &def->ips[jj]; + for (j = 0; j < nIps; j++) { + virNetworkIpDefPtr def2 = &def->ips[j]; if (VIR_SOCKET_ADDR_FAMILY(&gwdef->gateway) != VIR_SOCKET_ADDR_FAMILY(&def2->address)) { continue; @@ -2247,7 +2249,7 @@ virNetworkDNSDefFormat(virBufferPtr buf, virNetworkDNSDefPtr def) { int result = 0; - int i; + size_t i, j; if (!(def->nhosts || def->nsrvs || def->ntxts)) goto out; @@ -2283,16 +2285,14 @@ virNetworkDNSDefFormat(virBufferPtr buf, } if (def->nhosts) { - int ii, j; - - for (ii = 0; ii < def->nhosts; ii++) { - char *ip = virSocketAddrFormat(&def->hosts[ii].ip); + for (i = 0; i < def->nhosts; i++) { + char *ip = virSocketAddrFormat(&def->hosts[i].ip); virBufferAsprintf(buf, "\n", ip); virBufferAdjustIndent(buf, 2); - for (j = 0; j < def->hosts[ii].nnames; j++) + for (j = 0; j < def->hosts[i].nnames; j++) virBufferAsprintf(buf, "%s\n", - def->hosts[ii].names[j]); + def->hosts[i].names[j]); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -2341,15 +2341,15 @@ virNetworkIpDefFormat(virBufferPtr buf, def->tftproot); } if ((def->nranges || def->nhosts)) { - int ii; + size_t i; virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - for (ii = 0; ii < def->nranges; ii++) { - char *saddr = virSocketAddrFormat(&def->ranges[ii].start); + for (i = 0; i < def->nranges; i++) { + char *saddr = virSocketAddrFormat(&def->ranges[i].start); if (!saddr) goto error; - char *eaddr = virSocketAddrFormat(&def->ranges[ii].end); + char *eaddr = virSocketAddrFormat(&def->ranges[i].end); if (!eaddr) { VIR_FREE(saddr); goto error; @@ -2359,16 +2359,16 @@ virNetworkIpDefFormat(virBufferPtr buf, VIR_FREE(saddr); VIR_FREE(eaddr); } - for (ii = 0; ii < def->nhosts; ii++) { + for (i = 0; i < def->nhosts; i++) { virBufferAddLit(buf, "hosts[ii].mac) - virBufferAsprintf(buf, "mac='%s' ", def->hosts[ii].mac); - if (def->hosts[ii].id) - virBufferAsprintf(buf, "id='%s' ", def->hosts[ii].id); - if (def->hosts[ii].name) - virBufferAsprintf(buf, "name='%s' ", def->hosts[ii].name); - if (VIR_SOCKET_ADDR_VALID(&def->hosts[ii].ip)) { - char *ipaddr = virSocketAddrFormat(&def->hosts[ii].ip); + if (def->hosts[i].mac) + virBufferAsprintf(buf, "mac='%s' ", def->hosts[i].mac); + if (def->hosts[i].id) + virBufferAsprintf(buf, "id='%s' ", def->hosts[i].id); + if (def->hosts[i].name) + virBufferAsprintf(buf, "name='%s' ", def->hosts[i].name); + if (VIR_SOCKET_ADDR_VALID(&def->hosts[i].ip)) { + char *ipaddr = virSocketAddrFormat(&def->hosts[i].ip); if (!ipaddr) goto error; virBufferAsprintf(buf, "ip='%s' ", ipaddr); @@ -2526,7 +2526,8 @@ virNetworkDefFormatInternal(virBufferPtr buf, { unsigned char *uuid; char uuidstr[VIR_UUID_STRING_BUFLEN]; - int ii, shortforward; + size_t i; + int shortforward; virBufferAddLit(buf, "connections > 0)) { @@ -2597,21 +2598,21 @@ virNetworkDefFormatInternal(virBufferPtr buf, if (def->forward.nifs && (!def->forward.npfs || !(flags & VIR_NETWORK_XML_INACTIVE))) { - for (ii = 0; ii < def->forward.nifs; ii++) { + for (i = 0; i < def->forward.nifs; i++) { if (def->forward.type != VIR_NETWORK_FORWARD_HOSTDEV) { virBufferEscapeString(buf, "forward.ifs[ii].device.dev); + def->forward.ifs[i].device.dev); if (!(flags & VIR_NETWORK_XML_INACTIVE) && - (def->forward.ifs[ii].connections > 0)) { + (def->forward.ifs[i].connections > 0)) { virBufferAsprintf(buf, " connections='%d'", - def->forward.ifs[ii].connections); + def->forward.ifs[i].connections); } virBufferAddLit(buf, "/>\n"); } else { - if (def->forward.ifs[ii].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) { + if (def->forward.ifs[i].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI) { if (virDevicePCIAddressFormat(buf, - def->forward.ifs[ii].device.pci, + def->forward.ifs[i].device.pci, true) < 0) goto error; } @@ -2656,21 +2657,21 @@ virNetworkDefFormatInternal(virBufferPtr buf, if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0) goto error; - for (ii = 0; ii < def->nips; ii++) { - if (virNetworkIpDefFormat(buf, &def->ips[ii]) < 0) + for (i = 0; i < def->nips; i++) { + if (virNetworkIpDefFormat(buf, &def->ips[i]) < 0) goto error; } - for (ii = 0; ii < def->nroutes; ii++) { - if (virNetworkRouteDefFormat(buf, &def->routes[ii]) < 0) + for (i = 0; i < def->nroutes; i++) { + if (virNetworkRouteDefFormat(buf, &def->routes[i]) < 0) goto error; } if (virNetDevVPortProfileFormat(def->virtPortProfile, buf) < 0) goto error; - for (ii = 0; ii < def->nPortGroups; ii++) - if (virPortGroupDefFormat(buf, &def->portGroups[ii]) < 0) + for (i = 0; i < def->nPortGroups; i++) + if (virPortGroupDefFormat(buf, &def->portGroups[i]) < 0) goto error; virBufferAdjustIndent(buf, -2); @@ -2740,14 +2741,14 @@ error: virPortGroupDefPtr virPortGroupFindByName(virNetworkDefPtr net, const char *portgroup) { - int ii; - for (ii = 0; ii < net->nPortGroups; ii++) { + size_t i; + for (i = 0; i < net->nPortGroups; i++) { if (portgroup) { - if (STREQ(portgroup, net->portGroups[ii].name)) - return &net->portGroups[ii]; + if (STREQ(portgroup, net->portGroups[i].name)) + return &net->portGroups[i]; } else { - if (net->portGroups[ii].isDefault) - return &net->portGroups[ii]; + if (net->portGroups[i].isDefault) + return &net->portGroups[i]; } } return NULL; @@ -3093,7 +3094,7 @@ int virNetworkBridgeInUse(const virNetworkObjListPtr nets, const char *bridge, const char *skipname) { - unsigned int i; + size_t i; unsigned int ret = 0; for (i = 0; i < nets->count; i++) { @@ -3247,7 +3248,7 @@ static virNetworkIpDefPtr virNetworkIpDefByIndex(virNetworkDefPtr def, int parentIndex) { virNetworkIpDefPtr ipdef = NULL; - int ii; + size_t i; /* first find which ip element's dhcp host list to work on */ if (parentIndex >= 0) { @@ -3264,9 +3265,9 @@ virNetworkIpDefByIndex(virNetworkDefPtr def, int parentIndex) /* -1 means "find the most appropriate", which in this case * means the one and only that has element */ - for (ii = 0; - (ipdef = virNetworkDefGetIpByIndex(def, AF_UNSPEC, ii)); - ii++) { + for (i = 0; + (ipdef = virNetworkDefGetIpByIndex(def, AF_UNSPEC, i)); + i++) { if (ipdef->nranges || ipdef->nhosts) break; } @@ -3291,7 +3292,8 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, ret = -1; + size_t i; + int ret = -1; virNetworkIpDefPtr ipdef = virNetworkIpDefByIndex(def, parentIndex); virNetworkDHCPHostDef host; @@ -3314,16 +3316,16 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, /* search for the entry with this (mac|name), * and update the IP+(mac|name) */ - for (ii = 0; ii < ipdef->nhosts; ii++) { + for (i = 0; i < ipdef->nhosts; i++) { if ((host.mac && - !virMacAddrCompare(host.mac, ipdef->hosts[ii].mac)) || + !virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) || (host.name && - STREQ_NULLABLE(host.name, ipdef->hosts[ii].name))) { + STREQ_NULLABLE(host.name, ipdef->hosts[i].name))) { break; } } - if (ii == ipdef->nhosts) { + if (i == ipdef->nhosts) { virReportError(VIR_ERR_OPERATION_INVALID, _("couldn't locate an existing dhcp host entry with " "\"mac='%s'\" in network '%s'"), @@ -3335,8 +3337,8 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, * then clear out the extra copy to get rid of the duplicate pointers * to its data (mac and name strings). */ - virNetworkDHCPHostDefClear(&ipdef->hosts[ii]); - ipdef->hosts[ii] = host; + virNetworkDHCPHostDefClear(&ipdef->hosts[i]); + ipdef->hosts[i] = host; memset(&host, 0, sizeof(host)); } else if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) || @@ -3348,13 +3350,13 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, } /* log error if an entry with same name/address/ip already exists */ - for (ii = 0; ii < ipdef->nhosts; ii++) { + for (i = 0; i < ipdef->nhosts; i++) { if ((host.mac && - !virMacAddrCompare(host.mac, ipdef->hosts[ii].mac)) || + !virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) || (host.name && - STREQ_NULLABLE(host.name, ipdef->hosts[ii].name)) || + STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) || (VIR_SOCKET_ADDR_VALID(&host.ip) && - virSocketAddrEqual(&host.ip, &ipdef->hosts[ii].ip))) { + virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip))) { char *ip = virSocketAddrFormat(&host.ip); virReportError(VIR_ERR_OPERATION_INVALID, @@ -3382,17 +3384,17 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, } /* find matching entry - all specified attributes must match */ - for (ii = 0; ii < ipdef->nhosts; ii++) { + for (i = 0; i < ipdef->nhosts; i++) { if ((!host.mac || - !virMacAddrCompare(host.mac, ipdef->hosts[ii].mac)) && + !virMacAddrCompare(host.mac, ipdef->hosts[i].mac)) && (!host.name || - STREQ_NULLABLE(host.name, ipdef->hosts[ii].name)) && + STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) && (!VIR_SOCKET_ADDR_VALID(&host.ip) || - virSocketAddrEqual(&host.ip, &ipdef->hosts[ii].ip))) { + virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip))) { break; } } - if (ii == ipdef->nhosts) { + if (i == ipdef->nhosts) { virReportError(VIR_ERR_OPERATION_INVALID, _("couldn't locate a matching dhcp host entry " "in network '%s'"), def->name); @@ -3400,8 +3402,8 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, } /* remove it */ - virNetworkDHCPHostDefClear(&ipdef->hosts[ii]); - VIR_DELETE_ELEMENT(ipdef->hosts, ii, ipdef->nhosts); + virNetworkDHCPHostDefClear(&ipdef->hosts[i]); + VIR_DELETE_ELEMENT(ipdef->hosts, i, ipdef->nhosts); } else { virNetworkDefUpdateUnknownCommand(command); @@ -3422,7 +3424,8 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, ret = -1; + size_t i; + int ret = -1; virNetworkIpDefPtr ipdef = virNetworkIpDefByIndex(def, parentIndex); virSocketAddrRange range; @@ -3448,9 +3451,9 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, goto cleanup; /* check if an entry with same name/address/ip already exists */ - for (ii = 0; ii < ipdef->nranges; ii++) { - if (virSocketAddrEqual(&range.start, &ipdef->ranges[ii].start) && - virSocketAddrEqual(&range.end, &ipdef->ranges[ii].end)) { + for (i = 0; i < ipdef->nranges; i++) { + if (virSocketAddrEqual(&range.start, &ipdef->ranges[i].start) && + virSocketAddrEqual(&range.end, &ipdef->ranges[i].end)) { break; } } @@ -3458,7 +3461,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) || (command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) { - if (ii < ipdef->nranges) { + if (i < ipdef->nranges) { char *startip = virSocketAddrFormat(&range.start); char *endip = virSocketAddrFormat(&range.end); @@ -3480,7 +3483,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, goto cleanup; } else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) { - if (ii == ipdef->nranges) { + if (i == ipdef->nranges) { virReportError(VIR_ERR_OPERATION_INVALID, _("couldn't locate a matching dhcp range entry " "in network '%s'"), def->name); @@ -3489,7 +3492,7 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, /* remove it */ /* NB: nothing to clear from a RangeDef that's being freed */ - VIR_DELETE_ELEMENT(ipdef->ranges, ii, ipdef->nranges); + VIR_DELETE_ELEMENT(ipdef->ranges, i, ipdef->nranges); } else { virNetworkDefUpdateUnknownCommand(command); @@ -3521,7 +3524,8 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, ret = -1; + size_t i; + int ret = -1; virNetworkForwardIfDef iface; memset(&iface, 0, sizeof(iface)); @@ -3545,17 +3549,17 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def, } /* check if an with same dev name already exists */ - for (ii = 0; ii < def->forward.nifs; ii++) { - if (def->forward.ifs[ii].type + for (i = 0; i < def->forward.nifs; i++) { + if (def->forward.ifs[i].type == VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_NETDEV && - STREQ(iface.device.dev, def->forward.ifs[ii].device.dev)) + STREQ(iface.device.dev, def->forward.ifs[i].device.dev)) break; } if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) || (command == VIR_NETWORK_UPDATE_COMMAND_ADD_LAST)) { - if (ii < def->forward.nifs) { + if (i < def->forward.nifs) { virReportError(VIR_ERR_OPERATION_INVALID, _("there is an existing interface entry " "in network '%s' that matches " @@ -3572,7 +3576,7 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def, goto cleanup; } else if (command == VIR_NETWORK_UPDATE_COMMAND_DELETE) { - if (ii == def->forward.nifs) { + if (i == def->forward.nifs) { virReportError(VIR_ERR_OPERATION_INVALID, _("couldn't find an interface entry " "in network '%s' matching "), @@ -3581,19 +3585,19 @@ virNetworkDefUpdateForwardInterface(virNetworkDefPtr def, } /* fail if the interface is being used */ - if (def->forward.ifs[ii].connections > 0) { + if (def->forward.ifs[i].connections > 0) { virReportError(VIR_ERR_OPERATION_INVALID, _("unable to delete interface '%s' " "in network '%s'. It is currently being used " " by %d domains."), iface.device.dev, def->name, - def->forward.ifs[ii].connections); + def->forward.ifs[i].connections); goto cleanup; } /* remove it */ - virNetworkForwardIfDefClear(&def->forward.ifs[ii]); - VIR_DELETE_ELEMENT(def->forward.ifs, ii, def->forward.nifs); + virNetworkForwardIfDefClear(&def->forward.ifs[i]); + VIR_DELETE_ELEMENT(def->forward.ifs, i, def->forward.nifs); } else { virNetworkDefUpdateUnknownCommand(command); @@ -3626,7 +3630,8 @@ virNetworkDefUpdatePortGroup(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, foundName = -1, foundDefault = -1; + size_t i; + int foundName = -1, foundDefault = -1; int ret = -1; virPortGroupDef portgroup; @@ -3639,11 +3644,11 @@ virNetworkDefUpdatePortGroup(virNetworkDefPtr def, goto cleanup; /* check if a portgroup with same name already exists */ - for (ii = 0; ii < def->nPortGroups; ii++) { - if (STREQ(portgroup.name, def->portGroups[ii].name)) - foundName = ii; - if (def->portGroups[ii].isDefault) - foundDefault = ii; + for (i = 0; i < def->nPortGroups; i++) { + if (STREQ(portgroup.name, def->portGroups[i].name)) + foundName = i; + if (def->portGroups[i].isDefault) + foundDefault = i; } if (foundName == -1 && ((command == VIR_NETWORK_UPDATE_COMMAND_MODIFY) || @@ -3719,7 +3724,8 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, jj, kk, foundIdx = -1, ret = -1; + size_t i, j, k; + int foundIdx = -1, ret = -1; virNetworkDNSDefPtr dns = &def->dns; virNetworkDNSHostDef host; bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || @@ -3741,21 +3747,21 @@ virNetworkDefUpdateDNSHost(virNetworkDefPtr def, if (virNetworkDNSHostDefParseXML(def->name, ctxt->node, &host, !isAdd) < 0) goto cleanup; - for (ii = 0; ii < dns->nhosts; ii++) { + for (i = 0; i < dns->nhosts; i++) { bool foundThisTime = false; - if (virSocketAddrEqual(&host.ip, &dns->hosts[ii].ip)) + if (virSocketAddrEqual(&host.ip, &dns->hosts[i].ip)) foundThisTime = true; - for (jj = 0; jj < host.nnames && !foundThisTime; jj++) { - for (kk = 0; kk < dns->hosts[ii].nnames && !foundThisTime; kk++) { - if (STREQ(host.names[jj], dns->hosts[ii].names[kk])) + for (j = 0; j < host.nnames && !foundThisTime; j++) { + for (k = 0; k < dns->hosts[i].nnames && !foundThisTime; k++) { + if (STREQ(host.names[j], dns->hosts[i].names[k])) foundThisTime = true; } } if (foundThisTime) { foundCt++; - foundIdx = ii; + foundIdx = i; } } @@ -3812,7 +3818,8 @@ virNetworkDefUpdateDNSSrv(virNetworkDefPtr def, /* virNetworkUpdateFlags */ unsigned int fflags ATTRIBUTE_UNUSED) { - int ii, foundIdx = -1, ret = -1; + size_t i; + int foundIdx = -1, ret = -1; virNetworkDNSDefPtr dns = &def->dns; virNetworkDNSSrvDef srv; bool isAdd = (command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST || @@ -3834,13 +3841,13 @@ virNetworkDefUpdateDNSSrv(virNetworkDefPtr def, if (virNetworkDNSSrvDefParseXML(def->name, ctxt->node, ctxt, &srv, !isAdd) < 0) goto cleanup; - for (ii = 0; ii < dns->nsrvs; ii++) { - if ((!srv.domain || STREQ_NULLABLE(srv.domain, dns->srvs[ii].domain)) && - (!srv.service || STREQ_NULLABLE(srv.service, dns->srvs[ii].service)) && - (!srv.protocol || STREQ_NULLABLE(srv.protocol, dns->srvs[ii].protocol)) && - (!srv.target || STREQ_NULLABLE(srv.target, dns->srvs[ii].target))) { + for (i = 0; i < dns->nsrvs; i++) { + if ((!srv.domain || STREQ_NULLABLE(srv.domain, dns->srvs[i].domain)) && + (!srv.service || STREQ_NULLABLE(srv.service, dns->srvs[i].service)) && + (!srv.protocol || STREQ_NULLABLE(srv.protocol, dns->srvs[i].protocol)) && + (!srv.target || STREQ_NULLABLE(srv.target, dns->srvs[i].target))) { foundCt++; - foundIdx = ii; + foundIdx = i; } } @@ -4237,7 +4244,7 @@ virNetworkObjListExport(virConnectPtr conn, virNetworkPtr net = NULL; int nnets = 0; int ret = -1; - int i; + size_t i; if (nets && VIR_ALLOC_N(tmp_nets, netobjs.count + 1) < 0) goto cleanup; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index a2814e62447a3275a868965174abd6a83e2e8d30..799405e456dc650bd0772f62e9d123f3a5628e1e 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -88,7 +88,7 @@ virNodeDeviceObjPtr virNodeDeviceFindBySysfsPath(const virNodeDeviceObjListPtr devs, const char *sysfs_path) { - unsigned int i; + size_t i; for (i = 0; i < devs->count; i++) { virNodeDeviceObjLock(devs->objs[i]); @@ -106,7 +106,7 @@ virNodeDeviceFindBySysfsPath(const virNodeDeviceObjListPtr devs, virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < devs->count; i++) { virNodeDeviceObjLock(devs->objs[i]); @@ -158,7 +158,7 @@ void virNodeDeviceObjFree(virNodeDeviceObjPtr dev) void virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs) { - unsigned int i; + size_t i; for (i = 0; i < devs->count; i++) virNodeDeviceObjFree(devs->objs[i]); VIR_FREE(devs->objs); @@ -203,7 +203,7 @@ virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs, void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs, const virNodeDeviceObjPtr dev) { - unsigned int i; + size_t i; virNodeDeviceObjUnlock(dev); @@ -232,7 +232,7 @@ char *virNodeDeviceDefFormat(const virNodeDeviceDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; virNodeDevCapsDefPtr caps; - unsigned int i = 0; + size_t i = 0; virBufferAddLit(&buf, "\n"); virBufferEscapeString(&buf, " %s\n", def->name); @@ -566,7 +566,8 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, union _virNodeDevCapData *data) { xmlNodePtr orignode, *nodes = NULL; - int i, n, ret = -1; + size_t i; + int n, ret = -1; unsigned long long val; orignode = ctxt->node; @@ -735,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; @@ -986,7 +988,8 @@ virNodeDevCapPciDevIommuGroupParseXML(xmlXPathContextPtr ctxt, xmlNodePtr origNode = ctxt->node; xmlNodePtr *addrNodes = NULL; char *numberStr = NULL; - int nAddrNodes, ii, ret = -1; + int nAddrNodes, ret = -1; + size_t i; virPCIDeviceAddressPtr pciAddr = NULL; ctxt->node = iommuGroupNode; @@ -1008,9 +1011,9 @@ virNodeDevCapPciDevIommuGroupParseXML(xmlXPathContextPtr ctxt, if ((nAddrNodes = virXPathNodeSet("./address", ctxt, &addrNodes)) < 0) goto cleanup; - for (ii = 0; ii < nAddrNodes; ii++) { + for (i = 0; i < nAddrNodes; i++) { virDevicePCIAddress addr = { 0, 0, 0, 0, 0 }; - if (virDevicePCIAddressParseXML(addrNodes[ii], &addr) < 0) + if (virDevicePCIAddressParseXML(addrNodes[i], &addr) < 0) goto cleanup; if (VIR_ALLOC(pciAddr) < 0) goto cleanup; @@ -1227,7 +1230,8 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, virNodeDeviceDefPtr def; virNodeDevCapsDefPtr *next_cap; xmlNodePtr *nodes; - int n, i; + int n; + size_t i; if (VIR_ALLOC(def) < 0) return NULL; @@ -1436,7 +1440,7 @@ out: void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) { - int i = 0; + size_t i = 0; union _virNodeDevCapData *data = &caps->data; switch (caps->type) { @@ -1593,7 +1597,7 @@ virNodeDeviceObjListExport(virConnectPtr conn, virNodeDevicePtr device = NULL; int ndevices = 0; int ret = -1; - int i; + size_t i; if (devices && VIR_ALLOC_N(tmp_devices, devobjs.count + 1) < 0) goto cleanup; diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 664701debc6a4338cc3ae7e9787e71c587269042..a3901d367ea7f3a791476c2bfff85a3c9b540a9f 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -225,7 +225,7 @@ static const char ipsetflags_str[] = "ipsetflags"; static int intMapGetByInt(const struct int_map *intmap, int32_t attr, const char **res) { - int i = 0; + size_t i = 0; bool found = false; while (intmap[i].val && !found) { @@ -255,7 +255,7 @@ static int intMapGetByString(const struct int_map *intmap, const char *str, int casecmp, int32_t *result) { - int i = 0; + size_t i = 0; bool found = false; while (intmap[i].val && !found) { @@ -272,7 +272,7 @@ intMapGetByString(const struct int_map *intmap, const char *str, int casecmp, void virNWFilterRuleDefFree(virNWFilterRuleDefPtr def) { - int i; + size_t i; if (!def) return; @@ -312,7 +312,7 @@ virNWFilterEntryFree(virNWFilterEntryPtr entry) { void virNWFilterDefFree(virNWFilterDefPtr def) { - int i; + size_t i; if (!def) return; @@ -348,7 +348,7 @@ virNWFilterObjFree(virNWFilterObjPtr obj) void virNWFilterObjListFree(virNWFilterObjListPtr nwfilters) { - unsigned int i; + size_t i; for (i = 0; i < nwfilters->count; i++) virNWFilterObjFree(nwfilters->objs[i]); VIR_FREE(nwfilters->objs); @@ -361,7 +361,7 @@ virNWFilterRuleDefAddVar(virNWFilterRuleDefPtr nwf, nwItemDesc *item, const char *var) { - int i = 0; + size_t i = 0; virNWFilterVarAccessPtr varAccess; varAccess = virNWFilterVarAccessParse(var); @@ -410,7 +410,7 @@ void virNWFilterObjRemove(virNWFilterObjListPtr nwfilters, virNWFilterObjPtr nwfilter) { - unsigned int i; + size_t i; virNWFilterObjUnlock(nwfilter); @@ -786,7 +786,7 @@ parseStringItems(const struct int_map *int_map, const char *input, int32_t *flags, char sep) { int rc = 0; - unsigned int i, j; + size_t i, j; bool found; i = 0; @@ -818,7 +818,8 @@ static int printStringItems(virBufferPtr buf, const struct int_map *int_map, int32_t flags, const char *sep) { - unsigned int i, c = 0; + size_t i; + unsigned int c = 0; int32_t mask = 0x1; while (mask) { @@ -2354,7 +2355,7 @@ virNWFilterRuleParse(xmlNodePtr node) while (cur != NULL) { if (cur->type == XML_ELEMENT_NODE) { - int i = 0; + size_t i = 0; while (1) { if (found) i = found_i; @@ -2667,7 +2668,7 @@ virNWFilterObjPtr virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters, const unsigned char *uuid) { - unsigned int i; + size_t i; for (i = 0; i < nwfilters->count; i++) { virNWFilterObjLock(nwfilters->objs[i]); @@ -2683,7 +2684,7 @@ virNWFilterObjFindByUUID(virNWFilterObjListPtr nwfilters, virNWFilterObjPtr virNWFilterObjFindByName(virNWFilterObjListPtr nwfilters, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < nwfilters->count; i++) { virNWFilterObjLock(nwfilters->objs[i]); @@ -2751,7 +2752,7 @@ _virNWFilterDefLoopDetect(virConnectPtr conn, const char *filtername) { int rc = 0; - int i; + size_t i; virNWFilterEntryPtr entry; virNWFilterObjPtr obj; @@ -2818,7 +2819,7 @@ virNWFilterRegisterCallbackDriver(virNWFilterCallbackDriverPtr cbd) void virNWFilterUnRegisterCallbackDriver(virNWFilterCallbackDriverPtr cbd) { - int i = 0; + size_t i = 0; while (i < nCallbackDriver && callbackDrvArray[i] != cbd) i++; @@ -2834,7 +2835,7 @@ virNWFilterUnRegisterCallbackDriver(virNWFilterCallbackDriverPtr cbd) void virNWFilterCallbackDriversLock(void) { - int i; + size_t i; for (i = 0; i < nCallbackDriver; i++) callbackDrvArray[i]->vmDriverLock(); @@ -2843,7 +2844,7 @@ virNWFilterCallbackDriversLock(void) void virNWFilterCallbackDriversUnlock(void) { - int i; + size_t i; for (i = 0; i < nCallbackDriver; i++) callbackDrvArray[i]->vmDriverUnlock(); @@ -2860,7 +2861,7 @@ static virDomainObjListIterator virNWFilterDomainFWUpdateCB; int virNWFilterInstFiltersOnAllVMs(virConnectPtr conn) { - int i; + size_t i; struct domUpdateCBStruct cb = { .conn = conn, .step = STEP_APPLY_CURRENT, @@ -2878,7 +2879,7 @@ virNWFilterInstFiltersOnAllVMs(virConnectPtr conn) static int virNWFilterTriggerVMFilterRebuild(virConnectPtr conn) { - int i; + size_t i; int ret = 0; struct domUpdateCBStruct cb = { .conn = conn, @@ -3201,7 +3202,7 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, const virXMLAttr2Struct *att, virNWFilterRuleDefPtr def) { - int i = 0, j; + size_t i = 0, j; bool typeShown = false; bool neverShown = true; bool asHex; @@ -3340,7 +3341,7 @@ err_exit: static char * virNWFilterRuleDefFormat(virNWFilterRuleDefPtr def) { - int i; + size_t i; virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf2 = VIR_BUFFER_INITIALIZER; char *data; @@ -3427,7 +3428,7 @@ virNWFilterDefFormat(virNWFilterDefPtr def) { virBuffer buf = VIR_BUFFER_INITIALIZER; char uuid[VIR_UUID_STRING_BUFLEN]; - int i; + size_t i; char *xml; virBufferAsprintf(&buf, "valType) { case NWFILTER_VALUE_TYPE_SIMPLE: @@ -299,7 +300,7 @@ virNWFilterVarValueDelValue(virNWFilterVarValuePtr val, const char *value) void virNWFilterVarCombIterFree(virNWFilterVarCombIterPtr ci) { - unsigned int i; + size_t i; if (!ci) return; @@ -314,7 +315,7 @@ static int virNWFilterVarCombIterGetIndexByIterId(virNWFilterVarCombIterPtr ci, unsigned int iterId) { - unsigned int i; + size_t i; for (i = 0; i < ci->nIter; i++) if (ci->iter[i].iterId == iterId) @@ -402,7 +403,7 @@ static bool virNWFilterVarCombIterEntryAreUniqueEntries(virNWFilterVarCombIterEntryPtr cie, virNWFilterHashTablePtr hash) { - unsigned int i, j; + size_t i, j; virNWFilterVarValuePtr varValue, tmp; const char *value; @@ -463,7 +464,8 @@ virNWFilterVarCombIterCreate(virNWFilterHashTablePtr hash, size_t nVarAccess) { virNWFilterVarCombIterPtr res; - unsigned int i, iterId; + size_t i; + unsigned int iterId; int iterIndex = -1; unsigned int nextIntIterId = VIR_NWFILTER_MAX_ITERID + 1; @@ -516,7 +518,7 @@ err_exit: virNWFilterVarCombIterPtr virNWFilterVarCombIterNext(virNWFilterVarCombIterPtr ci) { - unsigned int i; + size_t i; for (i = 0; i < ci->nIter; i++) { next: @@ -543,7 +545,8 @@ const char * virNWFilterVarCombIterGetVarValue(virNWFilterVarCombIterPtr ci, const virNWFilterVarAccessPtr vap) { - unsigned int i, iterId; + size_t i; + unsigned int iterId; bool found = false; const char *res = NULL; virNWFilterVarValuePtr value; @@ -675,7 +678,7 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table, void virNWFilterHashTableFree(virNWFilterHashTablePtr table) { - int i; + size_t i; if (!table) return; virHashFree(table->hashTable); @@ -706,7 +709,7 @@ void * virNWFilterHashTableRemoveEntry(virNWFilterHashTablePtr ht, const char *entry) { - int i; + size_t i; void *value = virHashSteal(ht->hashTable, entry); if (value) { @@ -886,7 +889,8 @@ virNWFilterFormatParamAttributes(virBufferPtr buf, const char *filterref) { virHashKeyValuePairPtr items; - int i, j, card, numKeys; + size_t i, j; + int card, numKeys; numKeys = virHashSize(table->hashTable); diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 4610737fd08e94cbb18735a7523e6b0d7b625ecf..2a52418dadd5954ba94c3693dc9cdebf79ea2f03 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -86,7 +86,7 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk) void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) { - int i; + size_t i; if (!def) return; @@ -178,7 +178,8 @@ virDomainSnapshotDefParseString(const char *xmlStr, virDomainSnapshotDefPtr def = NULL; virDomainSnapshotDefPtr ret = NULL; xmlNodePtr *nodes = NULL; - int i; + size_t i; + int n; char *creation = NULL, *state = NULL; struct timeval tv; int active; @@ -313,10 +314,10 @@ virDomainSnapshotDefParseString(const char *xmlStr, def->file = memoryFile; memoryFile = NULL; - if ((i = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) + if ((n = virXPathNodeSet("./disks/*", ctxt, &nodes)) < 0) goto cleanup; if (flags & VIR_DOMAIN_SNAPSHOT_PARSE_DISKS) { - def->ndisks = i; + def->ndisks = n; if (def->ndisks && VIR_ALLOC_N(def->disks, def->ndisks) < 0) goto cleanup; for (i = 0; i < def->ndisks; i++) { @@ -324,7 +325,7 @@ virDomainSnapshotDefParseString(const char *xmlStr, goto cleanup; } VIR_FREE(nodes); - } else if (i) { + } else if (n) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("unable to handle disk requests in snapshot")); goto cleanup; @@ -379,7 +380,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, { int ret = -1; virBitmapPtr map = NULL; - int i; + size_t i; int ndisks; bool inuse; @@ -568,7 +569,7 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, int internal) { virBuffer buf = VIR_BUFFER_INITIALIZER; - int i; + size_t i; virCheckFlags(VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_UPDATE_CPU, NULL); @@ -767,7 +768,7 @@ virDomainSnapshotObjListGetNames(virDomainSnapshotObjListPtr snapshots, { struct virDomainSnapshotNameData data = { names, maxnames, flags, 0, false }; - int i; + size_t i; if (!from) { /* LIST_ROOTS and LIST_DESCENDANTS have the same bit value, @@ -1009,7 +1010,7 @@ virDomainListSnapshots(virDomainSnapshotObjListPtr snapshots, virDomainSnapshotPtr *list = NULL; char **names; int ret = -1; - int i; + size_t i; if (!snaps || count < 0) return count; @@ -1043,7 +1044,7 @@ cleanup: bool virDomainSnapshotDefIsExternal(virDomainSnapshotDefPtr def) { - int i; + size_t i; if (def->memory == VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) return true; diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 507f6dd5ed9feea655024b5cb8f8abbd98a7ba41..524a4d6b7b8ad5b42dc78682790c77f206ce002f 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -264,7 +264,7 @@ static virStoragePoolTypeInfo poolTypeInfo[] = { static virStoragePoolTypeInfoPtr virStoragePoolTypeInfoLookup(int type) { - unsigned int i; + size_t i; for (i = 0; i < ARRAY_CARDINALITY(poolTypeInfo); i++) if (poolTypeInfo[i].poolType == type) return &poolTypeInfo[i]; @@ -296,7 +296,7 @@ virStorageVolOptionsForPoolType(int type) void virStorageVolDefFree(virStorageVolDefPtr def) { - int i; + size_t i; if (!def) return; @@ -338,7 +338,7 @@ virStoragePoolSourceAdapterClear(virStoragePoolSourceAdapter adapter) void virStoragePoolSourceClear(virStoragePoolSourcePtr source) { - int i; + size_t i; if (!source) return; @@ -416,7 +416,7 @@ virStoragePoolObjFree(virStoragePoolObjPtr obj) void virStoragePoolObjListFree(virStoragePoolObjListPtr pools) { - unsigned int i; + size_t i; for (i = 0; i < pools->count; i++) virStoragePoolObjFree(pools->objs[i]); VIR_FREE(pools->objs); @@ -427,7 +427,7 @@ void virStoragePoolObjRemove(virStoragePoolObjListPtr pools, virStoragePoolObjPtr pool) { - unsigned int i; + size_t i; virStoragePoolObjUnlock(pool); @@ -527,7 +527,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, int ret = -1; xmlNodePtr relnode, *nodeset = NULL; char *authType = NULL; - int nsource, i; + int nsource; + size_t i; virStoragePoolOptionsPtr options; char *name = NULL; char *port = NULL; @@ -1039,7 +1040,7 @@ virStoragePoolSourceFormat(virBufferPtr buf, virStoragePoolOptionsPtr options, virStoragePoolSourcePtr src) { - int i, j; + size_t i, j; char uuid[VIR_UUID_STRING_BUFLEN]; virBufferAddLit(buf," \n"); @@ -1254,7 +1255,8 @@ virStorageVolDefParseXML(virStoragePoolDefPtr pool, char *unit = NULL; xmlNodePtr node; xmlNodePtr *nodes = NULL; - int i, n; + size_t i; + int n; options = virStorageVolOptionsForPoolType(pool->type); if (options == NULL) @@ -1524,7 +1526,7 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options, virBufferEscapeString(buf, " %s\n", def->compat); if (options->featureToString && def->features) { - int i; + size_t i; bool b; bool empty = virBitmapIsAllClear(def->features); @@ -1565,7 +1567,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool, virBufferAddLit(&buf, " \n"); if (def->source.nextent) { - int i; + size_t i; const char *thispath = NULL; for (i = 0; i < def->source.nextent; i++) { if (thispath == NULL || @@ -1621,7 +1623,7 @@ virStoragePoolObjPtr virStoragePoolObjFindByUUID(virStoragePoolObjListPtr pools, const unsigned char *uuid) { - unsigned int i; + size_t i; for (i = 0; i < pools->count; i++) { virStoragePoolObjLock(pools->objs[i]); @@ -1637,7 +1639,7 @@ virStoragePoolObjPtr virStoragePoolObjFindByName(virStoragePoolObjListPtr pools, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < pools->count; i++) { virStoragePoolObjLock(pools->objs[i]); @@ -1653,7 +1655,7 @@ virStoragePoolObjPtr virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr pool, virStoragePoolDefPtr def) { - unsigned int i, j; + size_t i, j; for (i = 0; i < pool->def->source.ndevice; i++) { for (j = 0; j < def->source.ndevice; j++) { @@ -1668,7 +1670,7 @@ virStoragePoolSourceFindDuplicateDevices(virStoragePoolObjPtr pool, void virStoragePoolObjClearVols(virStoragePoolObjPtr pool) { - unsigned int i; + size_t i; for (i = 0; i < pool->volumes.count; i++) virStorageVolDefFree(pool->volumes.objs[i]); @@ -1680,7 +1682,7 @@ virStorageVolDefPtr virStorageVolDefFindByKey(virStoragePoolObjPtr pool, const char *key) { - unsigned int i; + size_t i; for (i = 0; i < pool->volumes.count; i++) if (STREQ(pool->volumes.objs[i]->key, key)) @@ -1693,7 +1695,7 @@ virStorageVolDefPtr virStorageVolDefFindByPath(virStoragePoolObjPtr pool, const char *path) { - unsigned int i; + size_t i; for (i = 0; i < pool->volumes.count; i++) if (STREQ(pool->volumes.objs[i]->target.path, path)) @@ -1706,7 +1708,7 @@ virStorageVolDefPtr virStorageVolDefFindByName(virStoragePoolObjPtr pool, const char *name) { - unsigned int i; + size_t i; for (i = 0; i < pool->volumes.count; i++) if (STREQ(pool->volumes.objs[i]->name, name)) @@ -1934,7 +1936,7 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def) virStoragePoolOptionsPtr options; virBuffer buf = VIR_BUFFER_INITIALIZER; const char *type; - int i; + size_t i; options = virStoragePoolOptionsForPoolType(def->type); if (options == NULL) @@ -2034,7 +2036,7 @@ int virStoragePoolSourceFindDuplicate(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def) { - int i; + size_t i; int ret = 1; virStoragePoolObjPtr pool = NULL; virStoragePoolObjPtr matchpool = NULL; @@ -2197,7 +2199,7 @@ virStoragePoolObjListExport(virConnectPtr conn, virStoragePoolPtr pool = NULL; int npools = 0; int ret = -1; - int i; + size_t i; if (pools && VIR_ALLOC_N(tmp_pools, poolobjs.count + 1) < 0) goto cleanup; diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c index f52500f6817a6ee9d1d18660d6e57b05738eb3f8..86b5f961a7ea7bb0c9156fe6c5f36ee3bc673501 100644 --- a/src/conf/storage_encryption_conf.c +++ b/src/conf/storage_encryption_conf.c @@ -130,7 +130,8 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt) xmlNodePtr *nodes = NULL; virStorageEncryptionPtr ret; char *format_str; - int format, i, n; + int format, n; + size_t i; if (VIR_ALLOC(ret) < 0) return NULL;