Convert 'int i' to 'size_t i' in src/{xen,xenapi,xenxs} files

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@redhat.com>
This commit is contained in:
Daniel P. Berrange 2013-07-08 15:09:33 +01:00
parent 111f6f4d73
commit 632180d14f
11 changed files with 104 additions and 81 deletions

View File

@ -78,7 +78,7 @@ read_stat(const char *path)
{ {
char str[64]; char str[64];
int64_t r; int64_t r;
int i; size_t i;
FILE *fp; FILE *fp;
fp = fopen(path, "r"); fp = fopen(path, "r");
@ -109,7 +109,7 @@ read_bd_stat(int device, int domid, const char *str)
"/sys/devices/xen-backend/tap-%d-%d/statistics/%s" "/sys/devices/xen-backend/tap-%d-%d/statistics/%s"
}; };
int i; size_t i;
char *path; char *path;
int64_t r; int64_t r;

View File

@ -2445,7 +2445,8 @@ static int
xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev) xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev)
{ {
int numdomains; int numdomains;
int ret = -1, i; int ret = -1;
size_t i;
int *ids = NULL; int *ids = NULL;
char *bdf = NULL; char *bdf = NULL;
char *xref = NULL; char *xref = NULL;
@ -2768,7 +2769,7 @@ xenRegister(void)
void void
xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr list) xenUnifiedDomainInfoListFree(xenUnifiedDomainInfoListPtr list)
{ {
int i; size_t i;
if (list == NULL) if (list == NULL)
return; return;
@ -2841,7 +2842,7 @@ xenUnifiedRemoveDomainInfo(xenUnifiedDomainInfoListPtr list,
int id, char *name, int id, char *name,
unsigned char *uuid) unsigned char *uuid)
{ {
int i; size_t i;
for (i = 0; i < list->count; i++) { for (i = 0; i < list->count; i++) {
if (list->doms[i]->id == id && if (list->doms[i]->id == id &&
STREQ(list->doms[i]->name, name) && STREQ(list->doms[i]->name, name) &&

View File

@ -1267,7 +1267,7 @@ xenHypervisorSetSchedulerParameters(virConnectPtr conn,
virTypedParameterPtr params, virTypedParameterPtr params,
int nparams) int nparams)
{ {
int i; size_t i;
unsigned int val; unsigned int val;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
char buf[256]; char buf[256];
@ -2039,7 +2039,7 @@ xenHypervisorBuildCapabilities(virConnectPtr conn, virArch hostarch,
int nr_guest_archs) int nr_guest_archs)
{ {
virCapsPtr caps; virCapsPtr caps;
int i; size_t i;
int hv_major = hv_versions.hv >> 16; int hv_major = hv_versions.hv >> 16;
int hv_minor = hv_versions.hv & 0xFFFF; int hv_minor = hv_versions.hv & 0xFFFF;
@ -2219,7 +2219,7 @@ static virCapsPtr
xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn) xenHypervisorMakeCapabilitiesSunOS(virConnectPtr conn)
{ {
struct guest_arch guest_arches[32]; struct guest_arch guest_arches[32];
int i = 0; size_t i = 0;
virCapsPtr caps = NULL; virCapsPtr caps = NULL;
int pae, longmode; int pae, longmode;
const char *hvm; const char *hvm;
@ -2288,7 +2288,7 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
char line[1024], *str, *token; char line[1024], *str, *token;
regmatch_t subs[4]; regmatch_t subs[4];
char *saveptr = NULL; char *saveptr = NULL;
int i; size_t i;
char hvm_type[4] = ""; /* "vmx" or "svm" (or "" if not in CPU). */ char hvm_type[4] = ""; /* "vmx" or "svm" (or "" if not in CPU). */
int host_pae = 0; int host_pae = 0;
@ -2592,7 +2592,8 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn, const unsigned char *uuid)
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
virDomainDefPtr ret; virDomainDefPtr ret;
char *name; char *name;
int maxids = 100, nids, i, id; int maxids = 100, nids, id;
size_t i;
retry: retry:
if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) { if (!(XEN_GETDOMAININFOLIST_ALLOC(dominfos, maxids))) {
@ -2840,7 +2841,9 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
int maxCells) int maxCells)
{ {
xen_op_v2_sys op_sys; xen_op_v2_sys op_sys;
int i, j, ret; size_t i;
int cell;
int ret;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
if (priv->nbNodeCells < 0) { if (priv->nbNodeCells < 0) {
@ -2867,22 +2870,22 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
memset(&op_sys, 0, sizeof(op_sys)); memset(&op_sys, 0, sizeof(op_sys));
op_sys.cmd = XEN_V2_OP_GETAVAILHEAP; op_sys.cmd = XEN_V2_OP_GETAVAILHEAP;
for (i = startCell, j = 0; for (cell = startCell, i = 0;
i < priv->nbNodeCells && j < maxCells; i++, j++) { cell < priv->nbNodeCells && i < maxCells; cell++, i++) {
if (hv_versions.sys_interface >= 5) if (hv_versions.sys_interface >= 5)
op_sys.u.availheap5.node = i; op_sys.u.availheap5.node = cell;
else else
op_sys.u.availheap.node = i; op_sys.u.availheap.node = cell;
ret = xenHypervisorDoV2Sys(priv->handle, &op_sys); ret = xenHypervisorDoV2Sys(priv->handle, &op_sys);
if (ret < 0) { if (ret < 0) {
return -1; return -1;
} }
if (hv_versions.sys_interface >= 5) if (hv_versions.sys_interface >= 5)
freeMems[j] = op_sys.u.availheap5.avail_bytes; freeMems[i] = op_sys.u.availheap5.avail_bytes;
else else
freeMems[j] = op_sys.u.availheap.avail_bytes; freeMems[i] = op_sys.u.availheap.avail_bytes;
} }
return j; return i;
} }
@ -2970,7 +2973,8 @@ xenHypervisorGetVcpus(virConnectPtr conn,
int ret; int ret;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
virVcpuInfoPtr ipt; virVcpuInfoPtr ipt;
int nbinfo, i; int nbinfo;
size_t i;
if (sizeof(cpumap_t) & 7) { if (sizeof(cpumap_t) & 7) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",

View File

@ -72,7 +72,7 @@ xenInotifyXendDomainsDirLookup(virConnectPtr conn,
char **name, char **name,
unsigned char *uuid) unsigned char *uuid)
{ {
int i; size_t i;
virDomainDefPtr def; virDomainDefPtr def;
const char *uuid_str; const char *uuid_str;
unsigned char rawuuid[VIR_UUID_BUFLEN]; unsigned char rawuuid[VIR_UUID_BUFLEN];
@ -159,7 +159,7 @@ xenInotifyXendDomainsDirRemoveEntry(virConnectPtr conn, const char *fname)
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
const char *uuidstr = fname + strlen(XEND_DOMAINS_DIR) + 1; const char *uuidstr = fname + strlen(XEND_DOMAINS_DIR) + 1;
unsigned char uuid[VIR_UUID_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN];
int i; size_t i;
if (virUUIDParse(uuidstr, uuid) < 0) { if (virUUIDParse(uuidstr, uuid) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,

View File

@ -744,7 +744,7 @@ xenDaemonListDomainsOld(virConnectPtr xend)
struct sexpr *root = NULL; struct sexpr *root = NULL;
char **ret = NULL; char **ret = NULL;
int count = 0; int count = 0;
int i; size_t i;
struct sexpr *_for_i, *node; struct sexpr *_for_i, *node;
root = sexpr_get(xend, "/xend/domain"); root = sexpr_get(xend, "/xend/domain");
@ -1843,7 +1843,8 @@ xenDaemonDomainPinVcpu(virConnectPtr conn,
int maplen) int maplen)
{ {
char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64]; char buf[VIR_UUID_BUFLEN], mapstr[sizeof(cpumap_t) * 64];
int i, j, ret; size_t i, j;
int ret;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
virDomainDefPtr def = NULL; virDomainDefPtr def = NULL;
@ -1862,7 +1863,7 @@ xenDaemonDomainPinVcpu(virConnectPtr conn,
/* from bit map, build character string of mapped CPU numbers */ /* from bit map, build character string of mapped CPU numbers */
for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++) for (i = 0; i < maplen; i++) for (j = 0; j < 8; j++)
if (cpumap[i] & (1 << j)) { if (cpumap[i] & (1 << j)) {
snprintf(buf, sizeof(buf), "%d,", (8 * i) + j); snprintf(buf, sizeof(buf), "%zu,", (8 * i) + j);
strcat(mapstr, buf); strcat(mapstr, buf);
} }
if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
@ -2895,7 +2896,8 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
int maxnames) int maxnames)
{ {
struct sexpr *root = NULL; struct sexpr *root = NULL;
int i, ret = -1; size_t i;
int ret = -1;
struct sexpr *_for_i, *node; struct sexpr *_for_i, *node;
if (maxnames == 0) if (maxnames == 0)
@ -2905,8 +2907,6 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
if (root == NULL) if (root == NULL)
goto error; goto error;
ret = 0;
/* coverity[copy_paste_error] */ /* coverity[copy_paste_error] */
for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS; for (_for_i = root, node = root->u.s.car; _for_i->kind == SEXPR_CONS;
_for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) { _for_i = _for_i->u.s.cdr, node = _for_i->u.s.car) {
@ -2920,16 +2920,16 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
break; break;
} }
ret = 0;
cleanup: cleanup:
sexpr_free(root); sexpr_free(root);
return ret; return ret;
error: error:
for (i = 0; i < ret; ++i) for (i = 0; ret != -1 && i < ret; ++i)
VIR_FREE(names[i]); VIR_FREE(names[i]);
ret = -1;
goto cleanup; goto cleanup;
} }
@ -3117,7 +3117,7 @@ xenDaemonSetSchedulerParameters(virConnectPtr conn,
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
struct sexpr *root; struct sexpr *root;
char *sched_type = NULL; char *sched_type = NULL;
int i; size_t i;
int sched_nparam = 0; int sched_nparam = 0;
int ret = -1; int ret = -1;

View File

@ -1146,7 +1146,8 @@ xenXMListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
{ {
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
struct xenXMListIteratorContext ctx; struct xenXMListIteratorContext ctx;
int i, ret = -1; size_t i;
int ret = -1;
xenUnifiedLock(priv); xenUnifiedLock(priv);
@ -1313,7 +1314,7 @@ xenXMDomainDetachDeviceFlags(virConnectPtr conn,
virDomainDeviceDefPtr dev = NULL; virDomainDeviceDefPtr dev = NULL;
virDomainDefPtr def; virDomainDefPtr def;
int ret = -1; int ret = -1;
int i; size_t i;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1); virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG, -1);

View File

@ -223,7 +223,8 @@ xenStoreNumOfDomains(virConnectPtr conn)
{ {
unsigned int num; unsigned int num;
char **idlist = NULL, *endptr; char **idlist = NULL, *endptr;
int i, ret = -1, realnum = 0; size_t i;
int ret = -1, realnum = 0;
long id; long id;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
@ -264,7 +265,8 @@ xenStoreDoListDomains(virConnectPtr conn,
int maxids) int maxids)
{ {
char **idlist = NULL, *endptr; char **idlist = NULL, *endptr;
unsigned int num, i; unsigned int num;
size_t i;
int ret = -1; int ret = -1;
long id; long id;
@ -404,7 +406,8 @@ char *
xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac) xenStoreDomainGetNetworkID(virConnectPtr conn, int id, const char *mac)
{ {
char dir[80], path[128], **list = NULL, *val = NULL; char dir[80], path[128], **list = NULL, *val = NULL;
unsigned int len, i, num; unsigned int len, num;
size_t i;
char *ret = NULL; char *ret = NULL;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
@ -453,7 +456,8 @@ char *
xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev) xenStoreDomainGetDiskID(virConnectPtr conn, int id, const char *dev)
{ {
char dir[80], path[128], **list = NULL, *val = NULL; char dir[80], path[128], **list = NULL, *val = NULL;
unsigned int devlen, len, i, num; unsigned int devlen, len, num;
size_t i;
char *ret = NULL; char *ret = NULL;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
@ -525,7 +529,8 @@ char *
xenStoreDomainGetPCIID(virConnectPtr conn, int id, const char *bdf) xenStoreDomainGetPCIID(virConnectPtr conn, int id, const char *bdf)
{ {
char dir[80], path[128], **list = NULL, *val = NULL; char dir[80], path[128], **list = NULL, *val = NULL;
unsigned int len, i, num; unsigned int len, num;
size_t i;
char *ret = NULL; char *ret = NULL;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
@ -610,7 +615,7 @@ xenStoreDomainGetUUID(virConnectPtr conn, int id, unsigned char *uuid)
static void static void
xenStoreWatchListFree(xenStoreWatchListPtr list) xenStoreWatchListFree(xenStoreWatchListPtr list)
{ {
int i; size_t i;
for (i=0; i<list->count; i++) { for (i=0; i<list->count; i++) {
VIR_FREE(list->watches[i]->path); VIR_FREE(list->watches[i]->path);
VIR_FREE(list->watches[i]->token); VIR_FREE(list->watches[i]->token);
@ -687,7 +692,7 @@ xenStoreAddWatch(virConnectPtr conn,
int int
xenStoreRemoveWatch(virConnectPtr conn, const char *path, const char *token) xenStoreRemoveWatch(virConnectPtr conn, const char *path, const char *token)
{ {
int i; size_t i;
xenStoreWatchListPtr list; xenStoreWatchListPtr list;
xenUnifiedPrivatePtr priv = conn->privateData; xenUnifiedPrivatePtr priv = conn->privateData;
@ -736,7 +741,7 @@ xenStoreFindWatch(xenStoreWatchListPtr list,
const char *path, const char *path,
const char *token) const char *token)
{ {
int i; size_t i;
for (i = 0; i < list->count; i++) for (i = 0; i < list->count; i++)
if (STREQ(path, list->watches[i]->path) && if (STREQ(path, list->watches[i]->path) &&
STREQ(token, list->watches[i]->token)) STREQ(token, list->watches[i]->token))
@ -797,7 +802,8 @@ xenStoreDomainIntroduced(virConnectPtr conn,
const char *token ATTRIBUTE_UNUSED, const char *token ATTRIBUTE_UNUSED,
void *opaque) void *opaque)
{ {
int i, j, found, missing = 0, retries = 20; size_t i, j;
int found, missing = 0, retries = 20;
int new_domain_cnt; int new_domain_cnt;
int *new_domids; int *new_domids;
int nread; int nread;
@ -877,7 +883,8 @@ xenStoreDomainReleased(virConnectPtr conn,
const char *token ATTRIBUTE_UNUSED, const char *token ATTRIBUTE_UNUSED,
void *opaque) void *opaque)
{ {
int i, j, found, removed, retries = 20; size_t i, j;
int found, removed, retries = 20;
int new_domain_cnt; int new_domain_cnt;
int *new_domids; int *new_domids;
int nread; int nread;

View File

@ -295,7 +295,8 @@ xenapiConnectGetVersion(virConnectPtr conn, unsigned long *hvVer)
xen_host host; xen_host host;
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session; xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
xen_string_string_map *result = NULL; xen_string_string_map *result = NULL;
int i, ret = -1; size_t i;
int ret = -1;
char *version = NULL; char *version = NULL;
if (!(xen_session_get_this_host(session, &host, session))) { if (!(xen_session_get_this_host(session, &host, session))) {
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL); xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
@ -459,7 +460,7 @@ xenapiConnectListDomains(virConnectPtr conn, int *ids, int maxids)
xen_host host; xen_host host;
xen_vm_set *result = NULL; xen_vm_set *result = NULL;
int64_t t0; int64_t t0;
int i; size_t i;
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session; xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
if (xen_session_get_this_host(session, &host, session)) { if (xen_session_get_this_host(session, &host, session)) {
xen_host_get_resident_vms(session, &result, host); xen_host_get_resident_vms(session, &result, host);
@ -573,7 +574,7 @@ xenapiDomainCreateXML(virConnectPtr conn,
static virDomainPtr static virDomainPtr
xenapiDomainLookupByID(virConnectPtr conn, int id) xenapiDomainLookupByID(virConnectPtr conn, int id)
{ {
int i; size_t i;
int64_t domID; int64_t domID;
char *uuid; char *uuid;
xen_host host; xen_host host;
@ -1217,7 +1218,8 @@ xenapiDomainGetVcpus(virDomainPtr dom,
xen_vm_set *vms = NULL; xen_vm_set *vms = NULL;
xen_vm vm = NULL; xen_vm vm = NULL;
xen_string_string_map *vcpu_params = NULL; xen_string_string_map *vcpu_params = NULL;
int nvcpus = 0, i; int nvcpus = 0;
size_t i;
virDomainInfo domInfo; virDomainInfo domInfo;
virNodeInfo nodeInfo; virNodeInfo nodeInfo;
virVcpuInfoPtr ifptr; virVcpuInfoPtr ifptr;
@ -1383,7 +1385,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
} }
xen_vm_get_hvm_boot_params(session, &result, vm); xen_vm_get_hvm_boot_params(session, &result, vm);
if (result != NULL) { if (result != NULL) {
int i; size_t i;
for (i = 0; i < result->size; i++) { for (i = 0; i < result->size; i++) {
if (STREQ(result->contents[i].key, "order")) { if (STREQ(result->contents[i].key, "order")) {
int cnt = 0; int cnt = 0;
@ -1468,7 +1470,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
} }
xen_vm_get_platform(session, &result, vm); xen_vm_get_platform(session, &result, vm);
if (result != NULL) { if (result != NULL) {
int i; size_t i;
for (i = 0; i < result->size; i++) { for (i = 0; i < result->size; i++) {
if (STREQ(result->contents[i].val, "true")) { if (STREQ(result->contents[i].val, "true")) {
if (STREQ(result->contents[i].key, "acpi")) if (STREQ(result->contents[i].key, "acpi"))
@ -1487,7 +1489,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags)
} }
xen_vm_get_vifs(session, &vif_set, vm); xen_vm_get_vifs(session, &vif_set, vm);
if (vif_set) { if (vif_set) {
int i; size_t i;
xen_vif vif; xen_vif vif;
xen_vif_record *vif_rec = NULL; xen_vif_record *vif_rec = NULL;
xen_network network; xen_network network;
@ -1543,13 +1545,15 @@ static int
xenapiConnectListDefinedDomains(virConnectPtr conn, char **const names, xenapiConnectListDefinedDomains(virConnectPtr conn, char **const names,
int maxnames) int maxnames)
{ {
int i,j=0,doms; size_t i, j;
int doms;
xen_vm_set *result; xen_vm_set *result;
xen_vm_record *record; xen_vm_record *record;
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session; xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
xen_vm_get_all(session, &result); xen_vm_get_all(session, &result);
memset(names, 0, sizeof(names[0])*maxnames);
if (result != NULL) { if (result != NULL) {
for (i = 0; i < result->size && j < maxnames; i++) { for (i = 0, j = 0; i < result->size && j < maxnames; i++) {
xen_vm_get_record(session, &record, result->contents[i]); xen_vm_get_record(session, &record, result->contents[i]);
if (record != NULL) { if (record != NULL) {
if (record->is_a_template == 0) { if (record->is_a_template == 0) {
@ -1557,7 +1561,8 @@ xenapiConnectListDefinedDomains(virConnectPtr conn, char **const names,
if (VIR_STRDUP(usenames, record->name_label) < 0) { if (VIR_STRDUP(usenames, record->name_label) < 0) {
xen_vm_record_free(record); xen_vm_record_free(record);
xen_vm_set_free(result); xen_vm_set_free(result);
while (--j >= 0) VIR_FREE(names[j]); for (i = 0; i < maxnames; i++)
VIR_FREE(names[j]);
return -1; return -1;
} }
names[j++] = usenames; names[j++] = usenames;
@ -1567,8 +1572,9 @@ xenapiConnectListDefinedDomains(virConnectPtr conn, char **const names,
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR,
_("Couldn't get VM record")); _("Couldn't get VM record"));
xen_vm_set_free(result); xen_vm_set_free(result);
while (--j >= 0) VIR_FREE(names[j]); for (i = 0; i < maxnames; i++)
return -1; VIR_FREE(names[j]);
return -1;
} }
} }
doms = j; doms = j;
@ -1590,7 +1596,8 @@ xenapiConnectNumOfDefinedDomains(virConnectPtr conn)
{ {
xen_vm_set *result; xen_vm_set *result;
xen_vm_record *record; xen_vm_record *record;
int DomNum = 0, i; int DomNum = 0;
size_t i;
xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session; xen_session *session = ((struct _xenapiPrivate *)(conn->privateData))->session;
xen_vm_get_all(session, &result); xen_vm_get_all(session, &result);
if (result != NULL) { if (result != NULL) {
@ -1762,7 +1769,8 @@ xenapiDomainUndefine(virDomainPtr dom)
static int static int
xenapiDomainGetAutostart(virDomainPtr dom, int *autostart) xenapiDomainGetAutostart(virDomainPtr dom, int *autostart)
{ {
int i,flag=0; size_t i;
int flag = 0;
xen_vm_set *vms; xen_vm_set *vms;
xen_vm vm; xen_vm vm;
xen_string_string_map *result; xen_string_string_map *result;

View File

@ -41,7 +41,7 @@
void void
xenSessionFree(xen_session *session) xenSessionFree(xen_session *session)
{ {
int i; size_t i;
if (session->error_description != NULL) { if (session->error_description != NULL) {
for (i = 0; i < session->error_description_count; i++) for (i = 0; i < session->error_description_count; i++)
VIR_FREE(session->error_description[i]); VIR_FREE(session->error_description[i]);
@ -95,7 +95,7 @@ int
xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify) xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify)
{ {
int result = 0; int result = 0;
int i; size_t i;
for (i = 0; i < uri->paramsCount; i++) { for (i = 0; i < uri->paramsCount; i++) {
virURIParamPtr queryParam = &uri->params[i]; virURIParamPtr queryParam = &uri->params[i];
@ -161,7 +161,7 @@ createXenAPIBootOrderString(int nboot, int *bootDevs)
{ {
virBuffer ret = VIR_BUFFER_INITIALIZER; virBuffer ret = VIR_BUFFER_INITIALIZER;
char *val = NULL; char *val = NULL;
int i; size_t i;
for (i = 0; i < nboot; i++) { for (i = 0; i < nboot; i++) {
if (bootDevs[i] == VIR_DOMAIN_BOOT_FLOPPY) if (bootDevs[i] == VIR_DOMAIN_BOOT_FLOPPY)
val = (char *)"a"; val = (char *)"a";
@ -253,7 +253,7 @@ getStorageVolumeType(char *type)
char * char *
returnErrorFromSession(xen_session *session) returnErrorFromSession(xen_session *session)
{ {
int i; size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
for (i = 0; i < session->error_description_count; i++) { for (i = 0; i < session->error_description_count; i++) {
if (!i) if (!i)
@ -273,11 +273,11 @@ mapDomainPinVcpu(unsigned char *cpumap, int maplen)
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
size_t len; size_t len;
char *ret = NULL; char *ret = NULL;
int i, j; size_t i, j;
for (i = 0; i < maplen; i++) { for (i = 0; i < maplen; i++) {
for (j = 0; j < 8; j++) { for (j = 0; j < 8; j++) {
if (cpumap[i] & (1 << j)) { if (cpumap[i] & (1 << j)) {
virBufferAsprintf(&buf, "%d,", (8*i)+j); virBufferAsprintf(&buf, "%zu,", (8*i)+j);
} }
} }
} }
@ -450,7 +450,7 @@ createVMRecordFromXml(virConnectPtr conn, virDomainDefPtr def,
char uuidStr[VIR_UUID_STRING_BUFLEN]; char uuidStr[VIR_UUID_STRING_BUFLEN];
xen_string_string_map *strings = NULL; xen_string_string_map *strings = NULL;
int device_number = 0; int device_number = 0;
int i; size_t i;
*record = xen_vm_record_alloc(); *record = xen_vm_record_alloc();
if (VIR_STRDUP((*record)->name_label, def->name) < 0) if (VIR_STRDUP((*record)->name_label, def->name) < 0)

View File

@ -628,7 +628,7 @@ xenParseSxprSound(virDomainDefPtr def,
const char *str) const char *str)
{ {
if (STREQ(str, "all")) { if (STREQ(str, "all")) {
int i; size_t i;
/* /*
* Special compatibility code for Xen with a bogus * Special compatibility code for Xen with a bogus
@ -1338,7 +1338,7 @@ xenParseSxpr(const struct sexpr *root,
/* Floppy disk config */ /* Floppy disk config */
if (hvm) { if (hvm) {
const char *const fds[] = { "fda", "fdb" }; const char *const fds[] = { "fda", "fdb" };
int i; size_t i;
for (i = 0; i < ARRAY_CARDINALITY(fds); i++) { for (i = 0; i < ARRAY_CARDINALITY(fds); i++) {
tmp = sexpr_fmt_node(root, "domain/image/hvm/%s", fds[i]); tmp = sexpr_fmt_node(root, "domain/image/hvm/%s", fds[i]);
if ((tmp != NULL) && (tmp[0] != 0)) { if ((tmp != NULL) && (tmp[0] != 0)) {
@ -2049,7 +2049,7 @@ xenFormatSxprAllPCI(virDomainDefPtr def,
virBufferPtr buf) virBufferPtr buf)
{ {
int hasPCI = 0; int hasPCI = 0;
int i; size_t i;
for (i = 0; i < def->nhostdevs; i++) for (i = 0; i < def->nhostdevs; i++)
if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
@ -2106,7 +2106,7 @@ xenFormatSxprSound(virDomainDefPtr def,
virBufferPtr buf) virBufferPtr buf)
{ {
const char *str; const char *str;
int i; size_t i;
for (i = 0; i < def->nsounds; i++) { for (i = 0; i < def->nsounds; i++) {
if (!(str = virDomainSoundModelTypeToString(def->sounds[i]->model))) { if (!(str = virDomainSoundModelTypeToString(def->sounds[i]->model))) {
@ -2184,7 +2184,8 @@ xenFormatSxpr(virConnectPtr conn,
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
const char *tmp; const char *tmp;
char *bufout; char *bufout;
int hvm = 0, i, vmlocaltime = -1; int hvm = 0, vmlocaltime = -1;
size_t i;
bool in_image = false; bool in_image = false;
VIR_DEBUG("Formatting domain sexpr"); VIR_DEBUG("Formatting domain sexpr");
@ -2361,21 +2362,21 @@ xenFormatSxpr(virConnectPtr conn,
} }
if (def->serials) { if (def->serials) {
if ((def->nserials > 1) || (def->serials[0]->target.port != 0)) { if ((def->nserials > 1) || (def->serials[0]->target.port != 0)) {
int maxport = -1; int maxport = -1, port;
int j = 0; size_t j = 0;
virBufferAddLit(&buf, "(serial ("); virBufferAddLit(&buf, "(serial (");
for (i = 0; i < def->nserials; i++) for (i = 0; i < def->nserials; i++)
if (def->serials[i]->target.port > maxport) if (def->serials[i]->target.port > maxport)
maxport = def->serials[i]->target.port; maxport = def->serials[i]->target.port;
for (i = 0; i <= maxport; i++) { for (port = 0; port <= maxport; port++) {
virDomainChrDefPtr chr = NULL; virDomainChrDefPtr chr = NULL;
if (i) if (port)
virBufferAddLit(&buf, " "); virBufferAddLit(&buf, " ");
for (j = 0; j < def->nserials; j++) { for (j = 0; j < def->nserials; j++) {
if (def->serials[j]->target.port == i) { if (def->serials[j]->target.port == port) {
chr = def->serials[j]; chr = def->serials[j];
break; break;
} }

View File

@ -258,7 +258,7 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
virDomainNetDefPtr net = NULL; virDomainNetDefPtr net = NULL;
virDomainGraphicsDefPtr graphics = NULL; virDomainGraphicsDefPtr graphics = NULL;
virDomainHostdevDefPtr hostdev = NULL; virDomainHostdevDefPtr hostdev = NULL;
int i; size_t i;
const char *defaultMachine; const char *defaultMachine;
int vmlocaltime = 0; int vmlocaltime = 0;
unsigned long count; unsigned long count;
@ -1416,7 +1416,7 @@ xenFormatXMPCI(virConfPtr conf,
virConfValuePtr pciVal = NULL; virConfValuePtr pciVal = NULL;
int hasPCI = 0; int hasPCI = 0;
int i; size_t i;
for (i = 0; i < def->nhostdevs; i++) for (i = 0; i < def->nhostdevs; i++)
if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && if (def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
@ -1485,7 +1485,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
virDomainDefPtr def, virDomainDefPtr def,
int xendConfigVersion) { int xendConfigVersion) {
virConfPtr conf = NULL; virConfPtr conf = NULL;
int hvm = 0, i, vmlocaltime = 0; int hvm = 0, vmlocaltime = 0;
size_t i;
char *cpus = NULL; char *cpus = NULL;
const char *lifecycle; const char *lifecycle;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
@ -1935,8 +1936,8 @@ virConfPtr xenFormatXM(virConnectPtr conn,
if (ret < 0) if (ret < 0)
goto cleanup; goto cleanup;
} else { } else {
int j = 0; size_t j = 0;
int maxport = -1; int maxport = -1, port;
virConfValuePtr serialVal = NULL; virConfValuePtr serialVal = NULL;
if (VIR_ALLOC(serialVal) < 0) if (VIR_ALLOC(serialVal) < 0)
@ -1948,10 +1949,10 @@ virConfPtr xenFormatXM(virConnectPtr conn,
if (def->serials[i]->target.port > maxport) if (def->serials[i]->target.port > maxport)
maxport = def->serials[i]->target.port; maxport = def->serials[i]->target.port;
for (i = 0; i <= maxport; i++) { for (port = 0; port <= maxport; port++) {
virDomainChrDefPtr chr = NULL; virDomainChrDefPtr chr = NULL;
for (j = 0; j < def->nserials; j++) { for (j = 0; j < def->nserials; j++) {
if (def->serials[j]->target.port == i) { if (def->serials[j]->target.port == port) {
chr = def->serials[j]; chr = def->serials[j];
break; break;
} }