virDomainPtr dom;
const char *name;
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)))
return false;
xmlXPathContextPtr ctxt = NULL;
int ndisks;
xmlNodePtr *disks = NULL;
- int i;
+ size_t i;
bool details = false;
if (vshCommandOptBool(cmd, "inactive"))
xmlXPathContextPtr ctxt = NULL;
int ninterfaces;
xmlNodePtr *interfaces = NULL;
- int i;
+ size_t i;
if (vshCommandOptBool(cmd, "inactive"))
flags |= VIR_DOMAIN_XML_INACTIVE;
char *value = NULL;
const char *field = NULL;
int rc, nparams = 0;
- int i = 0;
+ size_t i;
bool ret = false;
bool human = vshCommandOptBool(cmd, "human"); /* human readable output */
virDomainPtr dom;
virDomainDiskErrorPtr disks = NULL;
unsigned int ndisks;
- int i;
+ size_t i;
int count;
bool ret = false;
static void
vshDomainListFree(vshDomainListPtr domlist)
{
- int i;
+ size_t i;
if (domlist && domlist->domains) {
for (i = 0; i < domlist->ndomains; i++) {
vshDomainListCollect(vshControl *ctl, unsigned int flags)
{
vshDomainListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
int *ids = NULL;
int nids = 0;
bool optTable = vshCommandOptBool(cmd, "table");
bool optUUID = vshCommandOptBool(cmd, "uuid");
bool optName = vshCommandOptBool(cmd, "name");
- int i;
+ size_t i;
char *title;
char uuid[VIR_UUID_STRING_BUFLEN];
int state;
int maxparams = 0;
virTypedParameterPtr params = NULL;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
- unsigned int i = 0;
+ size_t i;
int rv = 0;
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
int nparams = 0;
int maxparams = 0;
int rv = 0;
- unsigned int i = 0;
+ size_t i;
virTypedParameterPtr params = NULL;
bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool config;
bool ret = false;
unsigned int flags = 0;
- int i;
+ size_t i;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlXPathObjectPtr obj = NULL;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
virNetDevBandwidthRate inbound, outbound;
- int i;
+ size_t i;
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
char *def = NULL;
char *source = NULL;
char *target = NULL;
- int vol_i;
- int tok_i;
+ size_t i;
+ size_t j;
xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr *vol_nodes = NULL;
if (nvolumes > 0)
vlist = vshCalloc(ctl, nvolumes, sizeof(*vlist));
- for (vol_i = 0; vol_i < nvolumes; vol_i++) {
- ctxt->node = vol_nodes[vol_i];
+ for (i = 0; i < nvolumes; i++) {
+ ctxt->node = vol_nodes[i];
/* get volume source and target paths */
if (!(target = virXPathString("string(./target/@dev)", ctxt)))
/* lookup if volume was selected by user */
if (volumes) {
volume_tok = NULL;
- for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
- if (volume_tokens[tok_i] &&
- (STREQ(volume_tokens[tok_i], target) ||
- STREQ(volume_tokens[tok_i], source))) {
- volume_tok = volume_tokens[tok_i];
- volume_tokens[tok_i] = NULL;
+ for (j = 0; j < nvolume_tokens; j++) {
+ if (volume_tokens[j] &&
+ (STREQ(volume_tokens[j], target) ||
+ STREQ(volume_tokens[j], source))) {
+ volume_tok = volume_tokens[j];
+ volume_tokens[j] = NULL;
break;
}
}
/* print volumes specified by user that were not found in domain definition */
if (volumes) {
- for (tok_i = 0; tok_i < nvolume_tokens; tok_i++) {
- if (volume_tokens[tok_i]) {
+ for (j = 0; j < nvolume_tokens; j++) {
+ if (volume_tokens[j]) {
vshError(ctl, _("Volume '%s' was not found in domain's "
"definition.\n"),
- volume_tokens[tok_i]);
+ volume_tokens[j]);
vol_not_found = true;
}
}
/* try to undefine storage volumes associated with this domain, if it's requested */
if (nvols) {
- for (vol_i = 0; vol_i < nvols; vol_i++) {
+ for (i = 0; i < nvols; i++) {
if (wipe_storage) {
vshPrint(ctl, _("Wiping volume '%s'(%s) ... "),
- vlist[vol_i].target, vlist[vol_i].source);
+ vlist[i].target, vlist[i].source);
fflush(stdout);
- if (virStorageVolWipe(vlist[vol_i].vol, 0) < 0) {
+ if (virStorageVolWipe(vlist[i].vol, 0) < 0) {
vshError(ctl, _("Failed! Volume not removed."));
ret = false;
continue;
}
/* 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)"),
- vlist[vol_i].target, vlist[vol_i].source);
+ vlist[i].target, vlist[i].source);
ret = false;
} else {
vshPrint(ctl, _("Volume '%s'(%s) removed.\n"),
- vlist[vol_i].target, vlist[vol_i].source);
+ vlist[i].target, vlist[i].source);
}
}
}
cleanup:
- for (vol_i = 0; vol_i < nvols; vol_i++) {
- VIR_FREE(vlist[vol_i].source);
- VIR_FREE(vlist[vol_i].target);
- if (vlist[vol_i].vol)
- virStorageVolFree(vlist[vol_i].vol);
+ for (i = 0; i < nvols; i++) {
+ VIR_FREE(vlist[i].source);
+ VIR_FREE(vlist[i].target);
+ if (vlist[i].vol)
+ virStorageVolFree(vlist[i].vol);
}
VIR_FREE(vlist);
{
virTypedParameterPtr param;
int ret = -1;
- int i;
+ size_t i;
for (i = 0; i < nsrc_params; i++) {
param = &(src_params[i]);
virTypedParameterPtr updates = NULL;
int nparams = 0;
int nupdates = 0;
- int i, ret;
+ size_t i;
+ int ret;
bool ret_val = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
bool current = vshCommandOptBool(cmd, "current");
unsigned char *cpumap = NULL;
const char *cur;
bool unuse = false;
- int i, cpu, lastcpu;
+ int cpu, lastcpu;
+ size_t i;
cpumap = vshCalloc(ctl, cpumaplen, sizeof(*cpumap));
unsigned char *cpumap = NULL;
unsigned char *cpumaps = NULL;
size_t cpumaplen;
- int i, maxcpu, ncpus;
+ int maxcpu, ncpus;
+ size_t i;
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
if (vcpu != -1 && i != vcpu)
continue;
- vshPrint(ctl, "%4d: ", i);
+ vshPrint(ctl, "%4zu: ", i);
ret = vshPrintPinInfo(cpumaps, cpumaplen, maxcpu, i);
vshPrint(ctl, "\n");
if (!ret)
xmlXPathContextPtr ctxt = NULL;
xmlBufferPtr xml_buf = NULL;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- int i;
+ size_t i;
if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0)
return false;
{
virDomainPtr dom;
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;
unsigned int flags = 0;
bool ret = false;
for (i = 0; i < ncpus; i++) {
if (params[i * nparams].type == 0) /* this cpu is not in the map */
continue;
- vshPrint(ctl, "CPU%d:\n", cpu + i);
+ vshPrint(ctl, "CPU%zu:\n", cpu + i);
for (j = 0; j < nparams; j++) {
pos = i * nparams + j;
long long min_guarantee = 0;
int nparams = 0;
int maxparams = 0;
- unsigned int i = 0;
+ size_t i;
virTypedParameterPtr params = NULL;
bool ret = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
virDomainPtr dom;
int nparams = 0;
int maxparams = 0;
- unsigned int i = 0;
+ size_t i;
virTypedParameterPtr params = NULL;
const char *nodeset = NULL;
bool ret = false;
const char *mac =NULL, *type = NULL;
char *doc = NULL;
char buf[64];
- int i = 0, diff_mac;
+ int diff_mac;
+ size_t i;
int ret;
int functionReturn = false;
unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
}
/* 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;
while (cur != NULL) {
if (cur->type == XML_ELEMENT_NODE &&
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr cur = NULL;
xmlNodePtr ret = NULL;
- int i = 0;
+ size_t i;
xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt);
if (!xml) {
}
/* search disk using @path */
- for (; i < obj->nodesetval->nodeNr; i++) {
+ for (i = 0; i < obj->nodesetval->nodeNr; i++) {
bool is_supported = true;
if (type == VSH_FIND_DISK_CHANGEABLE) {
unsigned long long *nodes_free = NULL;
bool all = vshCommandOptBool(cmd, "all");
bool cellno = vshCommandOptBool(cmd, "cellno");
- int i;
+ size_t i;
char *cap_xml = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
static bool
cmdNodeCpuStats(vshControl *ctl, const vshCmd *cmd)
{
- int i, j;
+ size_t i, j;
bool flag_utilization = false;
bool flag_percent = vshCommandOptBool(cmd, "percent");
int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS;
cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
{
int nparams = 0;
- unsigned int i = 0;
+ size_t i;
int cellNum = VIR_NODE_MEMORY_STATS_ALL_CELLS;
virNodeMemoryStatsPtr params = NULL;
bool ret = false;
unsigned int value;
bool ret = false;
int rc = -1;
- int i = 0;
+ size_t i;
if ((rc = vshCommandOptUInt(cmd, "shm-pages-to-scan", &value)) < 0) {
vshError(ctl, "%s", _("invalid shm-pages-to-scan number"));
static void
vshInterfaceListFree(vshInterfaceListPtr list)
{
- int i;
+ size_t i;
if (list && list->nifaces) {
for (i = 0; i < list->nifaces; i++) {
unsigned int flags)
{
vshInterfaceListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
char **activeNames = NULL;
char **inactiveNames = NULL;
bool all = vshCommandOptBool(cmd, "all");
unsigned int flags = VIR_CONNECT_LIST_INTERFACES_ACTIVE;
vshInterfaceListPtr list = NULL;
- int i;
+ size_t i;
if (inactive)
flags = VIR_CONNECT_LIST_INTERFACES_INACTIVE;
static void
vshNetworkListFree(vshNetworkListPtr list)
{
- int i;
+ size_t i;
if (list && list->nnets) {
for (i = 0; i < list->nnets; i++) {
unsigned int flags)
{
vshNetworkListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
char **names = NULL;
virNetworkPtr net;
cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
vshNetworkListPtr list = NULL;
- int i;
+ size_t i;
bool inactive = vshCommandOptBool(cmd, "inactive");
bool all = vshCommandOptBool(cmd, "all");
bool persistent = vshCommandOptBool(cmd, "persistent");
static void
vshNodeDeviceListFree(vshNodeDeviceListPtr list)
{
- int i;
+ size_t i;
if (list && list->ndevices) {
for (i = 0; i < list->ndevices; i++) {
unsigned int flags)
{
vshNodeDeviceListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
virNodeDevicePtr device;
bool success = false;
/* Check if the device's capability matches with provied
* capabilities.
*/
- int j, k;
+ size_t j, k;
for (j = 0; j < ncaps; j++) {
for (k = 0; k < ncapnames; k++) {
if (STREQ(caps[j], capnames[k])) {
cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
const char *cap_str = NULL;
- int i;
+ size_t i;
bool tree = vshCommandOptBool(cmd, "tree");
bool ret = true;
unsigned int flags = 0;
static void
vshNWFilterListFree(vshNWFilterListPtr list)
{
- int i;
+ size_t i;
if (list && list->nfilters) {
for (i = 0; i < list->nfilters; i++) {
unsigned int flags)
{
vshNWFilterListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
virNWFilterPtr filter;
bool success = false;
success = true;
cleanup:
- for (i = 0; i < nfilters; i++)
+ for (i = 0; nfilters != -1 && i < nfilters; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
static bool
cmdNWFilterList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
- int i;
+ size_t i;
char uuid[VIR_UUID_STRING_BUFLEN];
vshNWFilterListPtr list = NULL;
static void
vshStoragePoolListFree(vshStoragePoolListPtr list)
{
- int i;
+ size_t i;
if (list && list->pools) {
for (i = 0; i < list->npools; i++) {
unsigned int flags)
{
vshStoragePoolListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
char **names = NULL;
virStoragePoolPtr pool;
cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
virStoragePoolInfo info;
- int i, ret;
+ int ret;
+ size_t i;
bool functionReturn = false;
size_t stringLength = 0, nameStrLength = 0;
size_t autostartStrLength = 0, persistStrLength = 0;
static void
vshSecretListFree(vshSecretListPtr list)
{
- int i;
+ size_t i;
if (list && list->nsecrets) {
for (i = 0; i < list->nsecrets; i++) {
unsigned int flags)
{
vshSecretListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
int ret;
virSecretPtr secret;
bool success = false;
success = true;
cleanup:
- for (i = 0; i < nsecrets; i++)
- VIR_FREE(uuids[i]);
- VIR_FREE(uuids);
+ if (nsecrets > 0) {
+ for (i = 0; i < nsecrets; i++)
+ VIR_FREE(uuids[i]);
+ VIR_FREE(uuids);
+ }
if (!success) {
vshSecretListFree(list);
static bool
cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
{
- int i;
+ size_t i;
vshSecretListPtr list = NULL;
bool ret = false;
unsigned int flags = 0;
const char *file = NULL;
char **array = NULL;
int narray;
- int i;
+ size_t i;
if (!str)
return 0;
const char *file = NULL;
char **array = NULL;
int narray;
- int i;
+ size_t i;
narray = vshStringToArray(str, &array);
if (narray <= 0)
static void
vshSnapshotListFree(vshSnapshotListPtr snaplist)
{
- int i;
+ size_t i;
if (!snaplist)
return;
virDomainSnapshotPtr from,
unsigned int orig_flags, bool tree)
{
- int i;
+ size_t i;
char **names = NULL;
int count = -1;
bool descendants = false;
changed = remaining = false;
for (i = 0; i < count; i++) {
bool found_parent = false;
- int j;
+ size_t j;
if (!names[i] || !snaplist->snaps[i].parent)
continue;
cleanup:
vshSnapshotListFree(snaplist);
- if (names)
+ if (names && count > 0)
for (i = 0; i < count; i++)
VIR_FREE(names[i]);
VIR_FREE(names);
virDomainPtr dom = NULL;
bool ret = false;
unsigned int flags = 0;
- int i;
+ size_t i;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
char *doc = NULL;
static void
vshStorageVolListFree(vshStorageVolListPtr list)
{
- int i;
+ size_t i;
if (list && list->vols) {
for (i = 0; i < list->nvols; i++) {
unsigned int flags)
{
vshStorageVolListPtr list = vshMalloc(ctl, sizeof(*list));
- int i;
+ size_t i;
char **names = NULL;
virStorageVolPtr vol = NULL;
bool success = false;
success = true;
cleanup:
- for (i = 0; i < nvols; i++)
- VIR_FREE(names[i]);
+ if (nvols > 0)
+ for (i = 0; i < nvols; i++)
+ VIR_FREE(names[i]);
VIR_FREE(names);
if (!success) {
const char *unit;
double val;
bool details = vshCommandOptBool(cmd, "details");
- int i;
+ size_t i;
int ret;
bool functionReturn = false;
int stringLength = 0;
bool root,
virBufferPtr indent)
{
- int i;
+ size_t i;
int nextlastdev = -1;
int ret = -1;
const char *dev = (lookup)(devid, false, opaque);
vshCmddefOptParse(const vshCmdDef *cmd, uint32_t *opts_need_arg,
uint32_t *opts_required)
{
- int i;
+ size_t i;
bool optional = false;
*opts_need_arg = 0;
continue;
}
if (opt->type == VSH_OT_ALIAS) {
- int j;
+ size_t j;
if (opt->flags || !opt->help)
return -1; /* alias options are tracked by the original name */
for (j = i + 1; cmd->opts[j].name; j++) {
vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name,
uint32_t *opts_seen, int *opt_index)
{
- int i;
+ size_t i;
if (STREQ(name, helpopt.name)) {
return &helpopt;
vshCmddefGetData(const vshCmdDef *cmd, uint32_t *opts_need_arg,
uint32_t *opts_seen)
{
- int i;
+ size_t i;
const vshCmdOptDef *opt;
if (!*opts_need_arg)
uint32_t opts_seen)
{
const vshCmdDef *def = cmd->def;
- int i;
+ size_t i;
opts_required &= ~opts_seen;
if (!opts_required)
static bool
vshParseArgv(vshControl *ctl, int argc, char **argv)
{
- int arg, len, debug, i;
+ int arg, len, debug;
+ size_t i;
int longindex = -1;
struct option opt[] = {
{"debug", required_argument, NULL, 'd'},