Convert 'int i' to 'size_t i' in tools/ 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 7a1e691711
commit 111f6f4d73
12 changed files with 107 additions and 96 deletions

View File

@ -323,7 +323,8 @@ cmdDomMemStat(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
const char *name; const char *name;
struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR];
unsigned int nr_stats, i; unsigned int nr_stats;
size_t i;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false; return false;
@ -454,7 +455,7 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
int ndisks; int ndisks;
xmlNodePtr *disks = NULL; xmlNodePtr *disks = NULL;
int i; size_t i;
bool details = false; bool details = false;
if (vshCommandOptBool(cmd, "inactive")) if (vshCommandOptBool(cmd, "inactive"))
@ -564,7 +565,7 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
int ninterfaces; int ninterfaces;
xmlNodePtr *interfaces = NULL; xmlNodePtr *interfaces = NULL;
int i; size_t i;
if (vshCommandOptBool(cmd, "inactive")) if (vshCommandOptBool(cmd, "inactive"))
flags |= VIR_DOMAIN_XML_INACTIVE; flags |= VIR_DOMAIN_XML_INACTIVE;
@ -880,7 +881,7 @@ cmdDomblkstat(vshControl *ctl, const vshCmd *cmd)
char *value = NULL; char *value = NULL;
const char *field = NULL; const char *field = NULL;
int rc, nparams = 0; int rc, nparams = 0;
int i = 0; size_t i;
bool ret = false; bool ret = false;
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */ bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
@ -1088,7 +1089,7 @@ cmdDomBlkError(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom; virDomainPtr dom;
virDomainDiskErrorPtr disks = NULL; virDomainDiskErrorPtr disks = NULL;
unsigned int ndisks; unsigned int ndisks;
int i; size_t i;
int count; int count;
bool ret = false; bool ret = false;
@ -1380,7 +1381,7 @@ typedef struct vshDomainList *vshDomainListPtr;
static void static void
vshDomainListFree(vshDomainListPtr domlist) vshDomainListFree(vshDomainListPtr domlist)
{ {
int i; size_t i;
if (domlist && domlist->domains) { if (domlist && domlist->domains) {
for (i = 0; i < domlist->ndomains; i++) { for (i = 0; i < domlist->ndomains; i++) {
@ -1396,7 +1397,7 @@ static vshDomainListPtr
vshDomainListCollect(vshControl *ctl, unsigned int flags) vshDomainListCollect(vshControl *ctl, unsigned int flags)
{ {
vshDomainListPtr list = vshMalloc(ctl, sizeof(*list)); vshDomainListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
int *ids = NULL; int *ids = NULL;
int nids = 0; int nids = 0;
@ -1702,7 +1703,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
bool optTable = vshCommandOptBool(cmd, "table"); bool optTable = vshCommandOptBool(cmd, "table");
bool optUUID = vshCommandOptBool(cmd, "uuid"); bool optUUID = vshCommandOptBool(cmd, "uuid");
bool optName = vshCommandOptBool(cmd, "name"); bool optName = vshCommandOptBool(cmd, "name");
int i; size_t i;
char *title; char *title;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
int state; int state;

View File

@ -1098,7 +1098,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
int maxparams = 0; int maxparams = 0;
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
unsigned int i = 0; size_t i;
int rv = 0; int rv = 0;
bool current = vshCommandOptBool(cmd, "current"); bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config"); bool config = vshCommandOptBool(cmd, "config");
@ -1276,7 +1276,7 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
int nparams = 0; int nparams = 0;
int maxparams = 0; int maxparams = 0;
int rv = 0; int rv = 0;
unsigned int i = 0; size_t i;
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
bool ret = false; bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
@ -2350,7 +2350,7 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
bool config; bool config;
bool ret = false; bool ret = false;
unsigned int flags = 0; unsigned int flags = 0;
int i; size_t i;
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlXPathObjectPtr obj = NULL; xmlXPathObjectPtr obj = NULL;
@ -2552,7 +2552,7 @@ cmdDomIftune(vshControl *ctl, const vshCmd *cmd)
bool config = vshCommandOptBool(cmd, "config"); bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live"); bool live = vshCommandOptBool(cmd, "live");
virNetDevBandwidthRate inbound, outbound; virNetDevBandwidthRate inbound, outbound;
int i; size_t i;
VSH_EXCLUSIVE_OPTIONS_VAR(current, live); VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config); VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
@ -2937,8 +2937,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
char *def = NULL; char *def = NULL;
char *source = NULL; char *source = NULL;
char *target = NULL; char *target = NULL;
int vol_i; size_t i;
int tok_i; size_t j;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlNodePtr *vol_nodes = NULL; xmlNodePtr *vol_nodes = NULL;
@ -3046,8 +3046,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
if (nvolumes > 0) if (nvolumes > 0)
vlist = vshCalloc(ctl, nvolumes, sizeof(*vlist)); vlist = vshCalloc(ctl, nvolumes, sizeof(*vlist));
for (vol_i = 0; vol_i < nvolumes; vol_i++) { for (i = 0; i < nvolumes; i++) {
ctxt->node = vol_nodes[vol_i]; ctxt->node = vol_nodes[i];
/* get volume source and target paths */ /* get volume source and target paths */
if (!(target = virXPathString("string(./target/@dev)", ctxt))) if (!(target = virXPathString("string(./target/@dev)", ctxt)))
@ -3067,12 +3067,12 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
/* lookup if volume was selected by user */ /* lookup if volume was selected by user */
if (volumes) { if (volumes) {
volume_tok = NULL; volume_tok = NULL;
for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) { for (j = 0; j < nvolume_tokens; j++) {
if (volume_tokens[tok_i] && if (volume_tokens[j] &&
(STREQ(volume_tokens[tok_i], target) || (STREQ(volume_tokens[j], target) ||
STREQ(volume_tokens[tok_i], source))) { STREQ(volume_tokens[j], source))) {
volume_tok = volume_tokens[tok_i]; volume_tok = volume_tokens[j];
volume_tokens[tok_i] = NULL; volume_tokens[j] = NULL;
break; break;
} }
} }
@ -3095,11 +3095,11 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
/* print volumes specified by user that were not found in domain definition */ /* print volumes specified by user that were not found in domain definition */
if (volumes) { if (volumes) {
for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) { for (j = 0; j < nvolume_tokens; j++) {
if (volume_tokens[tok_i]) { if (volume_tokens[j]) {
vshError(ctl, _("Volume '%s' was not found in domain's " vshError(ctl, _("Volume '%s' was not found in domain's "
"definition.\n"), "definition.\n"),
volume_tokens[tok_i]); volume_tokens[j]);
vol_not_found = true; vol_not_found = true;
} }
} }
@ -3162,12 +3162,12 @@ out:
/* try to undefine storage volumes associated with this domain, if it's requested */ /* try to undefine storage volumes associated with this domain, if it's requested */
if (nvols) { if (nvols) {
for (vol_i = 0; vol_i < nvols; vol_i++) { for (i = 0; i < nvols; i++) {
if (wipe_storage) { if (wipe_storage) {
vshPrint(ctl, _("Wiping volume '%s'(%s) ... "), vshPrint(ctl, _("Wiping volume '%s'(%s) ... "),
vlist[vol_i].target, vlist[vol_i].source); vlist[i].target, vlist[i].source);
fflush(stdout); fflush(stdout);
if (virStorageVolWipe(vlist[vol_i].vol, 0) < 0) { if (virStorageVolWipe(vlist[i].vol, 0) < 0) {
vshError(ctl, _("Failed! Volume not removed.")); vshError(ctl, _("Failed! Volume not removed."));
ret = false; ret = false;
continue; continue;
@ -3177,23 +3177,23 @@ out:
} }
/* delete the volume */ /* delete the volume */
if (virStorageVolDelete(vlist[vol_i].vol, 0) < 0) { if (virStorageVolDelete(vlist[i].vol, 0) < 0) {
vshError(ctl, _("Failed to remove storage volume '%s'(%s)"), vshError(ctl, _("Failed to remove storage volume '%s'(%s)"),
vlist[vol_i].target, vlist[vol_i].source); vlist[i].target, vlist[i].source);
ret = false; ret = false;
} else { } else {
vshPrint(ctl, _("Volume '%s'(%s) removed.\n"), vshPrint(ctl, _("Volume '%s'(%s) removed.\n"),
vlist[vol_i].target, vlist[vol_i].source); vlist[i].target, vlist[i].source);
} }
} }
} }
cleanup: cleanup:
for (vol_i = 0; vol_i < nvols; vol_i++) { for (i = 0; i < nvols; i++) {
VIR_FREE(vlist[vol_i].source); VIR_FREE(vlist[i].source);
VIR_FREE(vlist[vol_i].target); VIR_FREE(vlist[i].target);
if (vlist[vol_i].vol) if (vlist[i].vol)
virStorageVolFree(vlist[vol_i].vol); virStorageVolFree(vlist[i].vol);
} }
VIR_FREE(vlist); VIR_FREE(vlist);
@ -4020,7 +4020,7 @@ cmdSchedInfoUpdateOne(vshControl *ctl,
{ {
virTypedParameterPtr param; virTypedParameterPtr param;
int ret = -1; int ret = -1;
int i; size_t i;
for (i = 0; i < nsrc_params; i++) { for (i = 0; i < nsrc_params; i++) {
param = &(src_params[i]); param = &(src_params[i]);
@ -4114,7 +4114,8 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
virTypedParameterPtr updates = NULL; virTypedParameterPtr updates = NULL;
int nparams = 0; int nparams = 0;
int nupdates = 0; int nupdates = 0;
int i, ret; size_t i;
int ret;
bool ret_val = false; bool ret_val = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current"); bool current = vshCommandOptBool(cmd, "current");
@ -5530,7 +5531,8 @@ vshParseCPUList(vshControl *ctl, const char *cpulist,
unsigned char *cpumap = NULL; unsigned char *cpumap = NULL;
const char *cur; const char *cur;
bool unuse = false; bool unuse = false;
int i, cpu, lastcpu; int cpu, lastcpu;
size_t i;
cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap)); cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
@ -5625,7 +5627,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
unsigned char *cpumap = NULL; unsigned char *cpumap = NULL;
unsigned char *cpumaps = NULL; unsigned char *cpumaps = NULL;
size_t cpumaplen; size_t cpumaplen;
int i, maxcpu, ncpus; int maxcpu, ncpus;
size_t i;
bool config = vshCommandOptBool(cmd, "config"); bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live"); bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current"); bool current = vshCommandOptBool(cmd, "current");
@ -5695,7 +5698,7 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd)
if (vcpu != -1 && i != vcpu) if (vcpu != -1 && i != vcpu)
continue; continue;
vshPrint(ctl, "%4d: ", i); vshPrint(ctl, "%4zu: ", i);
ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, i); ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, i);
vshPrint(ctl, "\n"); vshPrint(ctl, "\n");
if (!ret) if (!ret)
@ -6102,7 +6105,7 @@ cmdCPUBaseline(vshControl *ctl, const vshCmd *cmd)
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlBufferPtr xml_buf = NULL; xmlBufferPtr xml_buf = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
int i; size_t i;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0) if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false; return false;
@ -6213,7 +6216,8 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
{ {
virDomainPtr dom; virDomainPtr dom;
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
int i, j, pos, max_id, cpu = 0, show_count = -1, nparams = 0; int pos, max_id, cpu = 0, show_count = -1, nparams = 0;
size_t i, j;
bool show_total = false, show_per_cpu = false; bool show_total = false, show_per_cpu = false;
unsigned int flags = 0; unsigned int flags = 0;
bool ret = false; bool ret = false;
@ -6286,7 +6290,7 @@ cmdCPUStats(vshControl *ctl, const vshCmd *cmd)
for (i = 0; i < ncpus; i++) { for (i = 0; i < ncpus; i++) {
if (params[i * nparams].type == 0) /* this cpu is not in the map */ if (params[i * nparams].type == 0) /* this cpu is not in the map */
continue; continue;
vshPrint(ctl, "CPU%d:\n", cpu + i); vshPrint(ctl, "CPU%zu:\n", cpu + i);
for (j = 0; j < nparams; j++) { for (j = 0; j < nparams; j++) {
pos = i * nparams + j; pos = i * nparams + j;
@ -7254,7 +7258,7 @@ cmdMemtune(vshControl *ctl, const vshCmd *cmd)
long long min_guarantee = 0; long long min_guarantee = 0;
int nparams = 0; int nparams = 0;
int maxparams = 0; int maxparams = 0;
unsigned int i = 0; size_t i;
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
bool ret = false; bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
@ -7419,7 +7423,7 @@ cmdNumatune(vshControl * ctl, const vshCmd * cmd)
virDomainPtr dom; virDomainPtr dom;
int nparams = 0; int nparams = 0;
int maxparams = 0; int maxparams = 0;
unsigned int i = 0; size_t i;
virTypedParameterPtr params = NULL; virTypedParameterPtr params = NULL;
const char *nodeset = NULL; const char *nodeset = NULL;
bool ret = false; bool ret = false;
@ -9507,7 +9511,8 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
const char *mac =NULL, *type = NULL; const char *mac =NULL, *type = NULL;
char *doc = NULL; char *doc = NULL;
char buf[64]; char buf[64];
int i = 0, diff_mac; int diff_mac;
size_t i;
int ret; int ret;
int functionReturn = false; int functionReturn = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
@ -9567,7 +9572,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
} }
/* multiple possibilities, so search for matching mac */ /* multiple possibilities, so search for matching mac */
for (; i < obj->nodesetval->nodeNr; i++) { for (i = 0; i < obj->nodesetval->nodeNr; i++) {
cur = obj->nodesetval->nodeTab[i]->children; cur = obj->nodesetval->nodeTab[i]->children;
while (cur != NULL) { while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE && if (cur->type == XML_ELEMENT_NODE &&
@ -9652,7 +9657,7 @@ vshFindDisk(const char *doc,
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
xmlNodePtr cur = NULL; xmlNodePtr cur = NULL;
xmlNodePtr ret = NULL; xmlNodePtr ret = NULL;
int i = 0; size_t i;
xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt); xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt);
if (!xml) { if (!xml) {
@ -9670,7 +9675,7 @@ vshFindDisk(const char *doc,
} }
/* search disk using @path */ /* search disk using @path */
for (; i < obj->nodesetval->nodeNr; i++) { for (i = 0; i < obj->nodesetval->nodeNr; i++) {
bool is_supported = true; bool is_supported = true;
if (type == VSH_FIND_DISK_CHANGEABLE) { if (type == VSH_FIND_DISK_CHANGEABLE) {

View File

@ -104,7 +104,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd)
unsigned long long *nodes_free = NULL; unsigned long long *nodes_free = NULL;
bool all = vshCommandOptBool(cmd, "all"); bool all = vshCommandOptBool(cmd, "all");
bool cellno = vshCommandOptBool(cmd, "cellno"); bool cellno = vshCommandOptBool(cmd, "cellno");
int i; size_t i;
char *cap_xml = NULL; char *cap_xml = NULL;
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
@ -297,7 +297,7 @@ static const vshCmdOptDef opts_node_cpustats[] = {
static bool static bool
cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd) cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
{ {
int i, j; size_t i, j;
bool flag_utilization = false; bool flag_utilization = false;
bool flag_percent = vshCommandOptBool(cmd, "percent"); bool flag_percent = vshCommandOptBool(cmd, "percent");
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS; int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
@ -429,7 +429,7 @@ static bool
cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
{ {
int nparams = 0; int nparams = 0;
unsigned int i = 0; size_t i;
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS; int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
virNodeMemoryStatsPtr params = NULL; virNodeMemoryStatsPtr params = NULL;
bool ret = false; bool ret = false;
@ -765,7 +765,7 @@ cmdNodeMemoryTune(vshControl *ctl, const vshCmd *cmd)
unsigned int value; unsigned int value;
bool ret = false; bool ret = false;
int rc = -1; int rc = -1;
int i = 0; size_t i;
if ((rc = vshCommandOptUInt(cmd, "shm-pages-to-scan", &value)) < 0) { if ((rc = vshCommandOptUInt(cmd, "shm-pages-to-scan", &value)) < 0) {
vshError(ctl, "%s", _("invalid shm-pages-to-scan number")); vshError(ctl, "%s", _("invalid shm-pages-to-scan number"));

View File

@ -172,7 +172,7 @@ typedef struct vshInterfaceList *vshInterfaceListPtr;
static void static void
vshInterfaceListFree(vshInterfaceListPtr list) vshInterfaceListFree(vshInterfaceListPtr list)
{ {
int i; size_t i;
if (list && list->nifaces) { if (list && list->nifaces) {
for (i = 0; i < list->nifaces; i++) { for (i = 0; i < list->nifaces; i++) {
@ -189,7 +189,7 @@ vshInterfaceListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list)); vshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
char **activeNames = NULL; char **activeNames = NULL;
char **inactiveNames = NULL; char **inactiveNames = NULL;
@ -349,7 +349,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
bool all = vshCommandOptBool(cmd, "all"); bool all = vshCommandOptBool(cmd, "all");
unsigned int flags = VIR_CONNECT_LIST_INTERFACES_ACTIVE; unsigned int flags = VIR_CONNECT_LIST_INTERFACES_ACTIVE;
vshInterfaceListPtr list = NULL; vshInterfaceListPtr list = NULL;
int i; size_t i;
if (inactive) if (inactive)
flags = VIR_CONNECT_LIST_INTERFACES_INACTIVE; flags = VIR_CONNECT_LIST_INTERFACES_INACTIVE;

View File

@ -421,7 +421,7 @@ typedef struct vshNetworkList *vshNetworkListPtr;
static void static void
vshNetworkListFree(vshNetworkListPtr list) vshNetworkListFree(vshNetworkListPtr list)
{ {
int i; size_t i;
if (list && list->nnets) { if (list && list->nnets) {
for (i = 0; i < list->nnets; i++) { for (i = 0; i < list->nnets; i++) {
@ -438,7 +438,7 @@ vshNetworkListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshNetworkListPtr list = vshMalloc(ctl, sizeof(*list)); vshNetworkListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
char **names = NULL; char **names = NULL;
virNetworkPtr net; virNetworkPtr net;
@ -658,7 +658,7 @@ static bool
cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
vshNetworkListPtr list = NULL; vshNetworkListPtr list = NULL;
int i; size_t i;
bool inactive = vshCommandOptBool(cmd, "inactive"); bool inactive = vshCommandOptBool(cmd, "inactive");
bool all = vshCommandOptBool(cmd, "all"); bool all = vshCommandOptBool(cmd, "all");
bool persistent = vshCommandOptBool(cmd, "persistent"); bool persistent = vshCommandOptBool(cmd, "persistent");

View File

@ -208,7 +208,7 @@ typedef struct vshNodeDeviceList *vshNodeDeviceListPtr;
static void static void
vshNodeDeviceListFree(vshNodeDeviceListPtr list) vshNodeDeviceListFree(vshNodeDeviceListPtr list)
{ {
int i; size_t i;
if (list && list->ndevices) { if (list && list->ndevices) {
for (i = 0; i < list->ndevices; i++) { for (i = 0; i < list->ndevices; i++) {
@ -227,7 +227,7 @@ vshNodeDeviceListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list)); vshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
virNodeDevicePtr device; virNodeDevicePtr device;
bool success = false; bool success = false;
@ -314,7 +314,7 @@ fallback:
/* Check if the device's capability matches with provied /* Check if the device's capability matches with provied
* capabilities. * capabilities.
*/ */
int j, k; size_t j, k;
for (j = 0; j < ncaps; j++) { for (j = 0; j < ncaps; j++) {
for (k = 0; k < ncapnames; k++) { for (k = 0; k < ncapnames; k++) {
if (STREQ(caps[j], capnames[k])) { if (STREQ(caps[j], capnames[k])) {
@ -393,7 +393,7 @@ static bool
cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
const char *cap_str = NULL; const char *cap_str = NULL;
int i; size_t i;
bool tree = vshCommandOptBool(cmd, "tree"); bool tree = vshCommandOptBool(cmd, "tree");
bool ret = true; bool ret = true;
unsigned int flags = 0; unsigned int flags = 0;

View File

@ -240,7 +240,7 @@ typedef struct vshNWFilterList *vshNWFilterListPtr;
static void static void
vshNWFilterListFree(vshNWFilterListPtr list) vshNWFilterListFree(vshNWFilterListPtr list)
{ {
int i; size_t i;
if (list && list->nfilters) { if (list && list->nfilters) {
for (i = 0; i < list->nfilters; i++) { for (i = 0; i < list->nfilters; i++) {
@ -257,7 +257,7 @@ vshNWFilterListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list)); vshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
virNWFilterPtr filter; virNWFilterPtr filter;
bool success = false; bool success = false;
@ -331,7 +331,7 @@ finished:
success = true; success = true;
cleanup: cleanup:
for (i = 0; i < nfilters; i++) for (i = 0; nfilters != -1 && i < nfilters; i++)
VIR_FREE(names[i]); VIR_FREE(names[i]);
VIR_FREE(names); VIR_FREE(names);
@ -363,7 +363,7 @@ static const vshCmdOptDef opts_nwfilter_list[] = {
static bool static bool
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
int i; size_t i;
char uuid[VIR_UUID_STRING_BUFLEN]; char uuid[VIR_UUID_STRING_BUFLEN];
vshNWFilterListPtr list = NULL; vshNWFilterListPtr list = NULL;

View File

@ -691,7 +691,7 @@ typedef struct vshStoragePoolList *vshStoragePoolListPtr;
static void static void
vshStoragePoolListFree(vshStoragePoolListPtr list) vshStoragePoolListFree(vshStoragePoolListPtr list)
{ {
int i; size_t i;
if (list && list->pools) { if (list && list->pools) {
for (i = 0; i < list->npools; i++) { for (i = 0; i < list->npools; i++) {
@ -708,7 +708,7 @@ vshStoragePoolListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list)); vshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
char **names = NULL; char **names = NULL;
virStoragePoolPtr pool; virStoragePoolPtr pool;
@ -943,7 +943,8 @@ static bool
cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
virStoragePoolInfo info; virStoragePoolInfo info;
int i, ret; int ret;
size_t i;
bool functionReturn = false; bool functionReturn = false;
size_t stringLength = 0, nameStrLength = 0; size_t stringLength = 0, nameStrLength = 0;
size_t autostartStrLength = 0, persistStrLength = 0; size_t autostartStrLength = 0, persistStrLength = 0;

View File

@ -367,7 +367,7 @@ typedef struct vshSecretList *vshSecretListPtr;
static void static void
vshSecretListFree(vshSecretListPtr list) vshSecretListFree(vshSecretListPtr list)
{ {
int i; size_t i;
if (list && list->nsecrets) { if (list && list->nsecrets) {
for (i = 0; i < list->nsecrets; i++) { for (i = 0; i < list->nsecrets; i++) {
@ -384,7 +384,7 @@ vshSecretListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshSecretListPtr list = vshMalloc(ctl, sizeof(*list)); vshSecretListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
int ret; int ret;
virSecretPtr secret; virSecretPtr secret;
bool success = false; bool success = false;
@ -461,9 +461,11 @@ finished:
success = true; success = true;
cleanup: cleanup:
for (i = 0; i < nsecrets; i++) if (nsecrets > 0) {
VIR_FREE(uuids[i]); for (i = 0; i < nsecrets; i++)
VIR_FREE(uuids); VIR_FREE(uuids[i]);
VIR_FREE(uuids);
}
if (!success) { if (!success) {
vshSecretListFree(list); vshSecretListFree(list);
@ -509,7 +511,7 @@ static const vshCmdOptDef opts_secret_list[] = {
static bool static bool
cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{ {
int i; size_t i;
vshSecretListPtr list = NULL; vshSecretListPtr list = NULL;
bool ret = false; bool ret = false;
unsigned int flags = 0; unsigned int flags = 0;

View File

@ -233,7 +233,7 @@ vshParseSnapshotMemspec(vshControl *ctl, virBufferPtr buf, const char *str)
const char *file = NULL; const char *file = NULL;
char **array = NULL; char **array = NULL;
int narray; int narray;
int i; size_t i;
if (!str) if (!str)
return 0; return 0;
@ -278,7 +278,7 @@ vshParseSnapshotDiskspec(vshControl *ctl, virBufferPtr buf, const char *str)
const char *file = NULL; const char *file = NULL;
char **array = NULL; char **array = NULL;
int narray; int narray;
int i; size_t i;
narray = vshStringToArray(str, &array); narray = vshStringToArray(str, &array);
if (narray <= 0) if (narray <= 0)
@ -1056,7 +1056,7 @@ typedef struct vshSnapshotList *vshSnapshotListPtr;
static void static void
vshSnapshotListFree(vshSnapshotListPtr snaplist) vshSnapshotListFree(vshSnapshotListPtr snaplist)
{ {
int i; size_t i;
if (!snaplist) if (!snaplist)
return; return;
@ -1095,7 +1095,7 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
virDomainSnapshotPtr from, virDomainSnapshotPtr from,
unsigned int orig_flags, bool tree) unsigned int orig_flags, bool tree)
{ {
int i; size_t i;
char **names = NULL; char **names = NULL;
int count = -1; int count = -1;
bool descendants = false; bool descendants = false;
@ -1347,7 +1347,7 @@ vshSnapshotListCollect(vshControl *ctl, virDomainPtr dom,
changed = remaining = false; changed = remaining = false;
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
bool found_parent = false; bool found_parent = false;
int j; size_t j;
if (!names[i] || !snaplist->snaps[i].parent) if (!names[i] || !snaplist->snaps[i].parent)
continue; continue;
@ -1408,7 +1408,7 @@ success:
cleanup: cleanup:
vshSnapshotListFree(snaplist); vshSnapshotListFree(snaplist);
if (names) if (names && count > 0)
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
VIR_FREE(names[i]); VIR_FREE(names[i]);
VIR_FREE(names); VIR_FREE(names);
@ -1517,7 +1517,7 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
bool ret = false; bool ret = false;
unsigned int flags = 0; unsigned int flags = 0;
int i; size_t i;
xmlDocPtr xml = NULL; xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL; xmlXPathContextPtr ctxt = NULL;
char *doc = NULL; char *doc = NULL;

View File

@ -1185,7 +1185,7 @@ typedef struct vshStorageVolList *vshStorageVolListPtr;
static void static void
vshStorageVolListFree(vshStorageVolListPtr list) vshStorageVolListFree(vshStorageVolListPtr list)
{ {
int i; size_t i;
if (list && list->vols) { if (list && list->vols) {
for (i = 0; i < list->nvols; i++) { for (i = 0; i < list->nvols; i++) {
@ -1203,7 +1203,7 @@ vshStorageVolListCollect(vshControl *ctl,
unsigned int flags) unsigned int flags)
{ {
vshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list)); vshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list));
int i; size_t i;
char **names = NULL; char **names = NULL;
virStorageVolPtr vol = NULL; virStorageVolPtr vol = NULL;
bool success = false; bool success = false;
@ -1273,8 +1273,9 @@ finished:
success = true; success = true;
cleanup: cleanup:
for (i = 0; i < nvols; i++) if (nvols > 0)
VIR_FREE(names[i]); for (i = 0; i < nvols; i++)
VIR_FREE(names[i]);
VIR_FREE(names); VIR_FREE(names);
if (!success) { if (!success) {
@ -1320,7 +1321,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
const char *unit; const char *unit;
double val; double val;
bool details = vshCommandOptBool(cmd, "details"); bool details = vshCommandOptBool(cmd, "details");
int i; size_t i;
int ret; int ret;
bool functionReturn = false; bool functionReturn = false;
int stringLength = 0; int stringLength = 0;

View File

@ -586,7 +586,7 @@ vshTreePrintInternal(vshControl *ctl,
bool root, bool root,
virBufferPtr indent) virBufferPtr indent)
{ {
int i; size_t i;
int nextlastdev = -1; int nextlastdev = -1;
int ret = -1; int ret = -1;
const char *dev = (lookup)(devid, false, opaque); const char *dev = (lookup)(devid, false, opaque);
@ -989,7 +989,7 @@ static int
vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg, vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
uint32_t *opts_required) uint32_t *opts_required)
{ {
int i; size_t i;
bool optional = false; bool optional = false;
*opts_need_arg = 0; *opts_need_arg = 0;
@ -1009,7 +1009,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
continue; continue;
} }
if (opt->type == VSH_OT_ALIAS) { if (opt->type == VSH_OT_ALIAS) {
int j; size_t j;
if (opt->flags || !opt->help) if (opt->flags || !opt->help)
return -1; /* alias options are tracked by the original name */ return -1; /* alias options are tracked by the original name */
for (j = i + 1; cmd->opts[j].name; j++) { for (j = i + 1; cmd->opts[j].name; j++) {
@ -1050,7 +1050,7 @@ static const vshCmdOptDef *
vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
uint32_t *opts_seen, int *opt_index) uint32_t *opts_seen, int *opt_index)
{ {
int i; size_t i;
if (STREQ(name, helpopt.name)) { if (STREQ(name, helpopt.name)) {
return &helpopt; return &helpopt;
@ -1085,7 +1085,7 @@ static const vshCmdOptDef *
vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg, vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
uint32_t *opts_seen) uint32_t *opts_seen)
{ {
int i; size_t i;
const vshCmdOptDef *opt; const vshCmdOptDef *opt;
if (!*opts_need_arg) if (!*opts_need_arg)
@ -1108,7 +1108,7 @@ vshCommandCheckOpts(vshControl *ctl, const vshCmd *cmd, uint32_t opts_required,
uint32_t opts_seen) uint32_t opts_seen)
{ {
const vshCmdDef *def = cmd->def; const vshCmdDef *def = cmd->def;
int i; size_t i;
opts_required &= ~opts_seen; opts_required &= ~opts_seen;
if (!opts_required) if (!opts_required)
@ -2972,7 +2972,8 @@ vshAllowedEscapeChar(char c)
static bool static bool
vshParseArgv(vshControl *ctl, int argc, char **argv) vshParseArgv(vshControl *ctl, int argc, char **argv)
{ {
int arg, len, debug, i; int arg, len, debug;
size_t i;
int longindex = -1; int longindex = -1;
struct option opt[] = { struct option opt[] = {
{"debug", required_argument, NULL, 'd'}, {"debug", required_argument, NULL, 'd'},