From: "Daniel P. Berrange" <berrange(a)redhat.com>
Convert the type of loop iterators named 'i', 'j', k',
'ii', 'jj', 'kk', to be 'size_t' instead of 'int'
or
'unsigned int', also santizing 'ii', 'jj', 'kk' to use
the normal 'i', 'j', 'k' naming
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/util/virbitmap.c | 13 +++++++------
src/util/vircgroup.c | 32 ++++++++++++++++----------------
src/util/vircommand.c | 10 +++++-----
src/util/virdnsmasq.c | 16 ++++++++--------
src/util/virebtables.c | 8 ++++----
src/util/vireventpoll.c | 28 ++++++++++++++--------------
src/util/virhook.c | 3 ++-
src/util/virjson.c | 12 ++++++------
src/util/virkeycode.c | 4 ++--
src/util/virlog.c | 30 +++++++++++++++---------------
src/util/virlog.h | 2 +-
src/util/virmacaddr.c | 2 +-
src/util/virnetdevmacvlan.c | 2 +-
src/util/virnetdevopenvswitch.c | 2 +-
src/util/virnetdevtap.c | 4 ++--
src/util/virnetdevvportprofile.c | 2 +-
src/util/virnetlink.c | 14 ++++++++------
src/util/virnuma.c | 13 +++++++------
src/util/virpci.c | 14 +++++++-------
src/util/virportallocator.c | 8 ++++----
src/util/virprocess.c | 7 ++++---
src/util/virscsi.c | 6 +++---
src/util/virsocketaddr.c | 28 ++++++++++++++--------------
src/util/virstoragefile.c | 7 ++++---
src/util/virstring.c | 3 ++-
src/util/virsysinfo.c | 6 +++---
src/util/virthreadwin32.c | 6 +++---
src/util/virthreadwin32.h | 2 +-
src/util/virtypedparam.c | 10 +++++-----
src/util/viruri.c | 2 +-
src/util/virusb.c | 6 +++---
src/util/virutil.c | 29 ++++++++++++++++-------------
src/util/viruuid.c | 7 ++++---
33 files changed, 175 insertions(+), 163 deletions(-)
diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c
index cf6a099..569654b 100644
--- a/src/util/virbitmap.c
+++ b/src/util/virbitmap.c
@@ -298,7 +298,8 @@ virBitmapParse(const char *str,
bool neg = false;
const char *cur;
char *tmp;
- int i, start, last;
+ size_t i;
+ int start, last;
if (!str)
return -1;
@@ -431,7 +432,7 @@ virBitmapPtr virBitmapNewCopy(virBitmapPtr src)
virBitmapPtr virBitmapNewData(void *data, int len)
{
virBitmapPtr bitmap;
- int i, j;
+ size_t i, j;
unsigned long *p;
unsigned char *bytes = data;
@@ -467,7 +468,7 @@ int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int
*dataLen)
{
int len;
unsigned long *l;
- int i, j;
+ size_t i, j;
unsigned char *bytes;
len = (bitmap->max_bit + CHAR_BIT - 1) / CHAR_BIT;
@@ -504,7 +505,7 @@ int virBitmapToData(virBitmapPtr bitmap, unsigned char **data, int
*dataLen)
bool virBitmapEqual(virBitmapPtr b1, virBitmapPtr b2)
{
virBitmapPtr tmp;
- int i;
+ size_t i;
if (b1->max_bit > b2->max_bit) {
tmp = b1;
@@ -571,7 +572,7 @@ void virBitmapClearAll(virBitmapPtr bitmap)
*/
bool virBitmapIsAllSet(virBitmapPtr bitmap)
{
- int i;
+ size_t i;
int unusedBits;
size_t sz;
@@ -602,7 +603,7 @@ bool virBitmapIsAllSet(virBitmapPtr bitmap)
*/
bool virBitmapIsAllClear(virBitmapPtr bitmap)
{
- int i;
+ size_t i;
for (i = 0; i < bitmap->map_len; i++)
if (bitmap->map[i] != 0)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index e0b25ed..8a78dc2 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -74,7 +74,7 @@ typedef enum {
*/
void virCgroupFree(virCgroupPtr *group)
{
- int i;
+ size_t i;
if (*group == NULL)
return;
@@ -111,7 +111,7 @@ bool virCgroupHasController(virCgroupPtr cgroup, int controller)
static int virCgroupCopyMounts(virCgroupPtr group,
virCgroupPtr parent)
{
- int i;
+ size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!parent->controllers[i].mountPoint)
continue;
@@ -133,7 +133,7 @@ static int virCgroupCopyMounts(virCgroupPtr group,
*/
static int virCgroupDetectMounts(virCgroupPtr group)
{
- int i;
+ size_t i;
FILE *mounts = NULL;
struct mntent entry;
char buf[CGROUP_MAX_VAL];
@@ -226,7 +226,7 @@ static int virCgroupCopyPlacement(virCgroupPtr group,
const char *path,
virCgroupPtr parent)
{
- int i;
+ size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!group->controllers[i].mountPoint)
continue;
@@ -279,7 +279,7 @@ static int virCgroupCopyPlacement(virCgroupPtr group,
static int virCgroupDetectPlacement(virCgroupPtr group,
const char *path)
{
- int i;
+ size_t i;
FILE *mapping = NULL;
char line[1024];
@@ -353,8 +353,8 @@ static int virCgroupDetect(virCgroupPtr group,
virCgroupPtr parent)
{
int rc;
- int i;
- int j;
+ size_t i;
+ size_t j;
VIR_DEBUG("group=%p controllers=%d path=%s parent=%p",
group, controllers, path, parent);
@@ -439,7 +439,7 @@ static int virCgroupDetect(virCgroupPtr group,
break;
}
- VIR_DEBUG("Detected mount/mapping %i:%s at %s in %s", i,
+ VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s", i,
virCgroupControllerTypeToString(i),
group->controllers[i].mountPoint,
group->controllers[i].placement);
@@ -459,7 +459,7 @@ int virCgroupPathOfController(virCgroupPtr group,
char **path)
{
if (controller == -1) {
- int i;
+ size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (group->controllers[i].mountPoint &&
group->controllers[i].placement) {
@@ -630,7 +630,7 @@ out:
#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
static int virCgroupCpuSetInherit(virCgroupPtr parent, virCgroupPtr group)
{
- int i;
+ size_t i;
int rc = 0;
const char *inherit_values[] = {
"cpuset.cpus",
@@ -702,7 +702,7 @@ static int virCgroupMakeGroup(virCgroupPtr parent,
bool create,
unsigned int flags)
{
- int i;
+ size_t i;
int rc = 0;
VIR_DEBUG("Make group %s", group->path);
@@ -938,7 +938,7 @@ int virCgroupRemoveRecursively(char *grppath ATTRIBUTE_UNUSED)
int virCgroupRemove(virCgroupPtr group)
{
int rc = 0;
- int i;
+ size_t i;
char *grppath = NULL;
VIR_DEBUG("Removing cgroup %s", group->path);
@@ -974,7 +974,7 @@ int virCgroupRemove(virCgroupPtr group)
int virCgroupAddTask(virCgroupPtr group, pid_t pid)
{
int rc = 0;
- int i;
+ size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
/* Skip over controllers not mounted */
@@ -1064,7 +1064,7 @@ int virCgroupMoveTask(virCgroupPtr src_group, virCgroupPtr
dest_group)
{
int rc = 0;
char *content = NULL;
- int i;
+ size_t i;
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
if (!src_group->controllers[i].mountPoint ||
@@ -2501,7 +2501,7 @@ int virCgroupKillRecursive(virCgroupPtr group, int signum)
int virCgroupKillPainfully(virCgroupPtr group)
{
- int i;
+ size_t i;
int rc;
VIR_DEBUG("cgroup=%p path=%s", group, group->path);
for (i = 0; i < 15; i++) {
@@ -2514,7 +2514,7 @@ int virCgroupKillPainfully(virCgroupPtr group)
signum = 0; /* Just check for existence */
rc = virCgroupKillRecursive(group, signum);
- VIR_DEBUG("Iteration %d rc=%d", i, rc);
+ VIR_DEBUG("Iteration %zu rc=%d", i, rc);
/* If rc == -1 we hit error, if 0 we ran out of PIDs */
if (rc <= 0)
break;
diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index 6e2eb1e..3e912a2 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -139,7 +139,7 @@ virCommandFDIsSet(int fd,
const int *set,
int set_size)
{
- int i = 0;
+ size_t i = 0;
while (i < set_size)
if (set[i++] == fd)
@@ -259,7 +259,7 @@ virFork(pid_t *pid)
/* child process */
int logprio;
- int i;
+ size_t i;
/* Remove any error callback so errors in child now
get sent to stderr where they stand a fighting chance
@@ -1857,7 +1857,7 @@ virCommandProcessIO(virCommandPtr cmd)
ret = -1;
for (;;) {
- int i;
+ size_t i;
struct pollfd fds[3];
int nfds = 0;
@@ -2176,7 +2176,7 @@ virCommandRunAsync(virCommandPtr cmd, pid_t *pid)
{
int ret = -1;
char *str;
- int i;
+ size_t i;
bool synchronous = false;
int infd[2] = {-1, -1};
@@ -2545,7 +2545,7 @@ int virCommandHandshakeNotify(virCommandPtr cmd)
void
virCommandFree(virCommandPtr cmd)
{
- int i;
+ size_t i;
if (!cmd)
return;
diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c
index d37ee3e..9f3e353 100644
--- a/src/util/virdnsmasq.c
+++ b/src/util/virdnsmasq.c
@@ -64,7 +64,7 @@ dhcphostFree(dnsmasqDhcpHost *host)
static void
addnhostFree(dnsmasqAddnHost *host)
{
- int i;
+ size_t i;
for (i = 0; i < host->nhostnames; i++)
VIR_FREE(host->hostnames[i]);
@@ -75,7 +75,7 @@ addnhostFree(dnsmasqAddnHost *host)
static void
addnhostsFree(dnsmasqAddnHostsfile *addnhostsfile)
{
- unsigned int i;
+ size_t i;
if (addnhostsfile->hosts) {
for (i = 0; i < addnhostsfile->nhosts; i++)
@@ -98,7 +98,7 @@ addnhostsAdd(dnsmasqAddnHostsfile *addnhostsfile,
{
char *ipstr = NULL;
int idx = -1;
- int i;
+ size_t i;
if (!(ipstr = virSocketAddrFormat(ip)))
return -1;
@@ -180,7 +180,7 @@ addnhostsWrite(const char *path,
char *tmp;
FILE *f;
bool istmp = true;
- unsigned int i, ii;
+ size_t i, j;
int rc = 0;
/* even if there are 0 hosts, create a 0 length file, to allow
@@ -209,8 +209,8 @@ addnhostsWrite(const char *path,
goto cleanup;
}
- for (ii = 0; ii < hosts[i].nhostnames; ii++) {
- if (fputs(hosts[i].hostnames[ii], f) == EOF || fputc('\t', f) == EOF)
{
+ for (j = 0; j < hosts[i].nhostnames; j++) {
+ if (fputs(hosts[i].hostnames[j], f) == EOF || fputc('\t', f) == EOF)
{
rc = -errno;
VIR_FORCE_FCLOSE(f);
@@ -282,7 +282,7 @@ genericFileDelete(char *path)
static void
hostsfileFree(dnsmasqHostsfile *hostsfile)
{
- unsigned int i;
+ size_t i;
if (hostsfile->hosts) {
for (i = 0; i < hostsfile->nhosts; i++)
@@ -391,7 +391,7 @@ hostsfileWrite(const char *path,
char *tmp;
FILE *f;
bool istmp = true;
- unsigned int i;
+ size_t i;
int rc = 0;
/* even if there are 0 hosts, create a 0 length file, to allow
diff --git a/src/util/virebtables.c b/src/util/virebtables.c
index 9c95d57..6819686 100644
--- a/src/util/virebtables.c
+++ b/src/util/virebtables.c
@@ -106,7 +106,7 @@ ebtRuleFree(ebtRule *rule)
VIR_FREE(rule->rule);
if (rule->argv) {
- int i = 0;
+ size_t i = 0;
while (rule->argv[i])
VIR_FREE(rule->argv[i++]);
VIR_FREE(rule->argv);
@@ -120,7 +120,7 @@ ebtRulesAppend(ebtRules *rules,
int command_idx)
{
if (VIR_REALLOC_N(rules->rules, rules->nrules+1) < 0) {
- int i = 0;
+ size_t i = 0;
while (argv[i])
VIR_FREE(argv[i++]);
VIR_FREE(argv);
@@ -140,7 +140,7 @@ static int
ebtRulesRemove(ebtRules *rules,
char *rule)
{
- int i;
+ size_t i;
for (i = 0; i < rules->nrules; i++)
if (STREQ(rules->rules[i].rule, rule))
@@ -163,7 +163,7 @@ ebtRulesRemove(ebtRules *rules,
static void
ebtRulesFree(ebtRules *rules)
{
- int i;
+ size_t i;
VIR_FREE(rules->table);
VIR_FREE(rules->chain);
diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c
index cc29dcb..f7d7e3d 100644
--- a/src/util/vireventpoll.c
+++ b/src/util/vireventpoll.c
@@ -140,7 +140,7 @@ int virEventPollAddHandle(int fd, int events,
}
void virEventPollUpdateHandle(int watch, int events) {
- int i;
+ size_t i;
bool found = false;
PROBE(EVENT_POLL_UPDATE_HANDLE,
"watch=%d events=%d",
@@ -174,7 +174,7 @@ void virEventPollUpdateHandle(int watch, int events) {
* Actual deletion will be done out-of-band
*/
int virEventPollRemoveHandle(int watch) {
- int i;
+ size_t i;
PROBE(EVENT_POLL_REMOVE_HANDLE,
"watch=%d",
watch);
@@ -190,7 +190,7 @@ int virEventPollRemoveHandle(int watch) {
continue;
if (eventLoop.handles[i].watch == watch) {
- EVENT_DEBUG("mark delete %d %d", i, eventLoop.handles[i].fd);
+ EVENT_DEBUG("mark delete %zu %d", i, eventLoop.handles[i].fd);
eventLoop.handles[i].deleted = 1;
virEventPollInterruptLocked();
virMutexUnlock(&eventLoop.lock);
@@ -253,7 +253,7 @@ int virEventPollAddTimeout(int frequency,
void virEventPollUpdateTimeout(int timer, int frequency)
{
unsigned long long now;
- int i;
+ size_t i;
bool found = false;
PROBE(EVENT_POLL_UPDATE_TIMEOUT,
"timer=%d frequency=%d",
@@ -294,7 +294,7 @@ void virEventPollUpdateTimeout(int timer, int frequency)
* Actual deletion will be done out-of-band
*/
int virEventPollRemoveTimeout(int timer) {
- int i;
+ size_t i;
PROBE(EVENT_POLL_REMOVE_TIMEOUT,
"timer=%d",
timer);
@@ -328,7 +328,7 @@ int virEventPollRemoveTimeout(int timer) {
*/
static int virEventPollCalculateTimeout(int *timeout) {
unsigned long long then = 0;
- int i;
+ size_t i;
EVENT_DEBUG("Calculate expiry of %zu timers", eventLoop.timeoutsCount);
/* Figure out if we need a timeout */
for (i = 0; i < eventLoop.timeoutsCount; i++) {
@@ -370,7 +370,7 @@ static int virEventPollCalculateTimeout(int *timeout) {
*/
static struct pollfd *virEventPollMakePollFDs(int *nfds) {
struct pollfd *fds;
- int i;
+ size_t i;
*nfds = 0;
for (i = 0; i < eventLoop.handlesCount; i++) {
@@ -386,7 +386,7 @@ static struct pollfd *virEventPollMakePollFDs(int *nfds) {
*nfds = 0;
for (i = 0; i < eventLoop.handlesCount; i++) {
- EVENT_DEBUG("Prepare n=%d w=%d, f=%d e=%d d=%d", i,
+ EVENT_DEBUG("Prepare n=%zu w=%d, f=%d e=%d d=%d", i,
eventLoop.handles[i].watch,
eventLoop.handles[i].fd,
eventLoop.handles[i].events,
@@ -419,7 +419,7 @@ static struct pollfd *virEventPollMakePollFDs(int *nfds) {
static int virEventPollDispatchTimeouts(void)
{
unsigned long long now;
- int i;
+ size_t i;
/* Save this now - it may be changed during dispatch */
int ntimeouts = eventLoop.timeoutsCount;
VIR_DEBUG("Dispatch %d", ntimeouts);
@@ -466,7 +466,7 @@ static int virEventPollDispatchTimeouts(void)
* Returns 0 upon success, -1 if an error occurred
*/
static int virEventPollDispatchHandles(int nfds, struct pollfd *fds) {
- int i, n;
+ size_t i, n;
VIR_DEBUG("Dispatch %d", nfds);
/* NB, use nfds not eventLoop.handlesCount, because new
@@ -481,9 +481,9 @@ static int virEventPollDispatchHandles(int nfds, struct pollfd *fds)
{
if (i == eventLoop.handlesCount)
break;
- VIR_DEBUG("i=%d w=%d", i, eventLoop.handles[i].watch);
+ VIR_DEBUG("i=%zu w=%d", i, eventLoop.handles[i].watch);
if (eventLoop.handles[i].deleted) {
- EVENT_DEBUG("Skip deleted n=%d w=%d f=%d", i,
+ EVENT_DEBUG("Skip deleted n=%zu w=%d f=%d", i,
eventLoop.handles[i].watch, eventLoop.handles[i].fd);
continue;
}
@@ -511,7 +511,7 @@ static int virEventPollDispatchHandles(int nfds, struct pollfd *fds)
{
* cleanup is needed to make dispatch re-entrant safe.
*/
static void virEventPollCleanupTimeouts(void) {
- int i;
+ size_t i;
size_t gap;
VIR_DEBUG("Cleanup %zu", eventLoop.timeoutsCount);
@@ -559,7 +559,7 @@ static void virEventPollCleanupTimeouts(void) {
* cleanup is needed to make dispatch re-entrant safe.
*/
static void virEventPollCleanupHandles(void) {
- int i;
+ size_t i;
size_t gap;
VIR_DEBUG("Cleanup %zu", eventLoop.handlesCount);
diff --git a/src/util/virhook.c b/src/util/virhook.c
index 507eae2..159efdb 100644
--- a/src/util/virhook.c
+++ b/src/util/virhook.c
@@ -139,7 +139,8 @@ virHookCheck(int no, const char *driver) {
*/
int
virHookInitialize(void) {
- int i, res, ret = 0;
+ size_t i;
+ int res, ret = 0;
virHooksFound = 0;
for (i = 0; i < VIR_HOOK_DRIVER_LAST; i++) {
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 3a6f520..e93def7 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -64,7 +64,7 @@ struct _virJSONParser {
void virJSONValueFree(virJSONValuePtr value)
{
- int i;
+ size_t i;
if (!value || value->protect)
return;
@@ -401,7 +401,7 @@ int virJSONValueArrayAppend(virJSONValuePtr array, virJSONValuePtr
value)
int virJSONValueObjectHasKey(virJSONValuePtr object, const char *key)
{
- int i;
+ size_t i;
if (object->type != VIR_JSON_TYPE_OBJECT)
return -1;
@@ -416,7 +416,7 @@ int virJSONValueObjectHasKey(virJSONValuePtr object, const char *key)
virJSONValuePtr virJSONValueObjectGet(virJSONValuePtr object, const char *key)
{
- int i;
+ size_t i;
if (object->type != VIR_JSON_TYPE_OBJECT)
return NULL;
@@ -455,7 +455,7 @@ int
virJSONValueObjectRemoveKey(virJSONValuePtr object, const char *key,
virJSONValuePtr *value)
{
- int i;
+ size_t i;
if (value)
*value = NULL;
@@ -1011,7 +1011,7 @@ cleanup:
yajl_free(hand);
if (parser.nstate) {
- int i;
+ size_t i;
for (i = 0; i < parser.nstate; i++) {
VIR_FREE(parser.state[i].key);
}
@@ -1026,7 +1026,7 @@ cleanup:
static int virJSONValueToStringOne(virJSONValuePtr object,
yajl_gen g)
{
- int i;
+ size_t i;
VIR_DEBUG("object=%p type=%d gen=%p", object, object->type, g);
diff --git a/src/util/virkeycode.c b/src/util/virkeycode.c
index 9b2809d..50594d6 100644
--- a/src/util/virkeycode.c
+++ b/src/util/virkeycode.c
@@ -90,7 +90,7 @@ VIR_ENUM_IMPL(virKeycodeSet, VIR_KEYCODE_SET_LAST,
int virKeycodeValueFromString(virKeycodeSet codeset,
const char *keyname)
{
- int i;
+ size_t i;
for (i = 0; i < VIR_KEYMAP_ENTRY_MAX; i++) {
if (!virKeymapNames[codeset] ||
@@ -111,7 +111,7 @@ int virKeycodeValueTranslate(virKeycodeSet from_codeset,
virKeycodeSet to_codeset,
int key_value)
{
- int i;
+ size_t i;
if (key_value <= 0)
return -1;
diff --git a/src/util/virlog.c b/src/util/virlog.c
index 064f8e8..568104f 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -366,7 +366,7 @@ virLogStr(const char *str)
static void
virLogDumpAllFD(const char *msg, int len)
{
- int i;
+ size_t i;
bool found = false;
if (len <= 0)
@@ -513,7 +513,7 @@ virLogSetDefaultPriority(virLogPriority priority)
static int
virLogResetFilters(void)
{
- int i;
+ size_t i;
for (i = 0; i < virLogNbFilters; i++)
VIR_FREE(virLogFilters[i].match);
@@ -541,7 +541,8 @@ virLogDefineFilter(const char *match,
virLogPriority priority,
unsigned int flags)
{
- int i;
+ size_t i;
+ int ret = -1;
char *mdup = NULL;
virCheckFlags(VIR_LOG_STACK_TRACE, -1);
@@ -554,17 +555,15 @@ virLogDefineFilter(const char *match,
for (i = 0; i < virLogNbFilters; i++) {
if (STREQ(virLogFilters[i].match, match)) {
virLogFilters[i].priority = priority;
+ ret = i;
goto cleanup;
}
}
- if (VIR_STRDUP_QUIET(mdup, match) < 0) {
- i = -1;
+ if (VIR_STRDUP_QUIET(mdup, match) < 0)
goto cleanup;
- }
- i = virLogNbFilters;
+ ret = virLogNbFilters;
if (VIR_REALLOC_N(virLogFilters, virLogNbFilters + 1)) {
- i = -1;
VIR_FREE(mdup);
goto cleanup;
}
@@ -574,9 +573,9 @@ virLogDefineFilter(const char *match,
virLogNbFilters++;
cleanup:
virLogUnlock();
- if (i < 0)
+ if (ret < 0)
virReportOOMError();
- return i;
+ return ret;
}
@@ -595,7 +594,7 @@ virLogFiltersCheck(const char *input,
unsigned int *flags)
{
int ret = 0;
- int i;
+ size_t i;
virLogLock();
for (i = 0; i < virLogNbFilters; i++) {
@@ -620,7 +619,7 @@ virLogFiltersCheck(const char *input,
static int
virLogResetOutputs(void)
{
- int i;
+ size_t i;
for (i = 0; i < virLogNbOutputs; i++) {
if (virLogOutputs[i].c != NULL)
@@ -805,7 +804,8 @@ virLogVMessage(virLogSource source,
char *str = NULL;
char *msg = NULL;
char timestamp[VIR_TIME_STRING_BUFLEN];
- int fprio, i, ret;
+ int fprio, ret;
+ size_t i;
int saved_errno = errno;
bool emit = true;
unsigned int filterflags = 0;
@@ -1486,7 +1486,7 @@ virLogGetDefaultPriority(void)
char *
virLogGetFilters(void)
{
- int i;
+ size_t i;
virBuffer filterbuf = VIR_BUFFER_INITIALIZER;
virLogLock();
@@ -1520,7 +1520,7 @@ virLogGetFilters(void)
char *
virLogGetOutputs(void)
{
- int i;
+ size_t i;
virBuffer outputbuf = VIR_BUFFER_INITIALIZER;
virLogLock();
diff --git a/src/util/virlog.h b/src/util/virlog.h
index 7db1657..f400824 100644
--- a/src/util/virlog.h
+++ b/src/util/virlog.h
@@ -97,7 +97,7 @@ static inline void virLogEatParams(virLogSource unused, ...)
struct _virLogMetadata {
const char *key;
const char *s; /* String value, or NULL to use "i" */
- int i;
+ int iv;
};
typedef struct _virLogMetadata virLogMetadata;
diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c
index c4ca0a84..2e9328d 100644
--- a/src/util/virmacaddr.c
+++ b/src/util/virmacaddr.c
@@ -146,7 +146,7 @@ virMacAddrGetRaw(virMacAddrPtr src, unsigned char
dst[VIR_MAC_BUFLEN])
int
virMacAddrParse(const char* str, virMacAddrPtr addr)
{
- int i;
+ size_t i;
errno = 0;
for (i = 0; i < VIR_MAC_BUFLEN; i++) {
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index a61c45f..00113af 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -596,7 +596,7 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *hdr,
if (virMacAddrCmpRaw(&calld->macaddress, mac->mac))
{
/* Repeat the same check for a broadcast mac */
- int i;
+ size_t i;
for (i = 0; i < VIR_MAC_BUFLEN; i++) {
if (calld->macaddress.addr[i] != 0xff) {
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index 75b196c..005b858 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -51,7 +51,7 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
virNetDevVlanPtr virtVlan)
{
int ret = -1;
- int i = 0;
+ size_t i = 0;
virCommandPtr cmd = NULL;
char macaddrstr[VIR_MAC_STRING_BUFLEN];
char ifuuidstr[VIR_UUID_STRING_BUFLEN];
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 4e2f32a..f018be1 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -156,7 +156,7 @@ int virNetDevTapCreate(char **ifname,
int tapfdSize,
unsigned int flags)
{
- int i;
+ size_t i;
struct ifreq ifr;
int ret = -1;
int fd;
@@ -311,7 +311,7 @@ int virNetDevTapCreate(char **ifname,
* matches this pattern
*/
if (strstr(*ifname, "%d") != NULL) {
- int i;
+ size_t i;
for (i = 0; i <= IF_MAXUNIT; i++) {
char *newname;
if (virAsprintf(&newname, *ifname, i) < 0) {
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 0f1b6a1..efd9692 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -783,7 +783,7 @@ virNetDevVPortProfileGetNthParent(const char *ifname, int ifindex,
unsigned int
int rc;
struct nlattr *tb[IFLA_MAX + 1] = { NULL, };
bool end = false;
- unsigned int i = 0;
+ size_t i = 0;
*nth = 0;
diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
index b2ba9df..6a584a0 100644
--- a/src/util/virnetlink.c
+++ b/src/util/virnetlink.c
@@ -326,7 +326,8 @@ virNetlinkEventCallback(int watch,
struct nlmsghdr *msg;
struct sockaddr_nl peer;
struct ucred *creds = NULL;
- int i, length;
+ size_t i;
+ int length;
bool handled = false;
length = nl_recv(srv->netlinknh, &peer,
@@ -349,7 +350,7 @@ virNetlinkEventCallback(int watch,
if (srv->handles[i].deleted != VIR_NETLINK_HANDLE_VALID)
continue;
- VIR_DEBUG("dispatching client %d.", i);
+ VIR_DEBUG("dispatching client %zu.", i);
(srv->handles[i].handleCB)(msg, length, &peer, &handled,
srv->handles[i].opaque);
@@ -378,7 +379,7 @@ virNetlinkEventServiceStop(unsigned int protocol)
return -EINVAL;
virNetlinkEventSrvPrivatePtr srv = server[protocol];
- int i;
+ size_t i;
VIR_INFO("stopping netlink event service");
@@ -414,7 +415,7 @@ virNetlinkEventServiceStop(unsigned int protocol)
int
virNetlinkEventServiceStopAll(void)
{
- unsigned int i, j;
+ size_t i, j;
virNetlinkEventSrvPrivatePtr srv = NULL;
VIR_INFO("stopping all netlink event services");
@@ -614,7 +615,8 @@ virNetlinkEventAddClient(virNetlinkEventHandleCallback handleCB,
void *opaque, const virMacAddrPtr macaddr,
unsigned int protocol)
{
- int i, r, ret = -1;
+ size_t i;
+ int r, ret = -1;
virNetlinkEventSrvPrivatePtr srv = NULL;
if (protocol >= MAX_LINKS)
@@ -689,7 +691,7 @@ int
virNetlinkEventRemoveClient(int watch, const virMacAddrPtr macaddr,
unsigned int protocol)
{
- int i;
+ size_t i;
int ret = -1;
virNetlinkEventSrvPrivatePtr srv = NULL;
diff --git a/src/util/virnuma.c b/src/util/virnuma.c
index 902ed43..ecf7ede 100644
--- a/src/util/virnuma.c
+++ b/src/util/virnuma.c
@@ -87,7 +87,8 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
int mode = -1;
int node = -1;
int ret = -1;
- int i = 0;
+ int bit = 0;
+ size_t i;
int maxnode = 0;
virBitmapPtr tmp_nodemask = NULL;
@@ -115,15 +116,15 @@ virNumaSetupMemoryPolicy(virNumaTuneDef numatune,
/* Convert nodemask to NUMA bitmask. */
nodemask_zero(&mask);
- i = -1;
- while ((i = virBitmapNextSetBit(tmp_nodemask, i)) >= 0) {
- if (i > maxnode || i > NUMA_NUM_NODES) {
+ bit = -1;
+ while ((bit = virBitmapNextSetBit(tmp_nodemask, bit)) >= 0) {
+ if (bit > maxnode || bit > NUMA_NUM_NODES) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Nodeset is out of range, host cannot support "
- "NUMA node bigger than %d"), i);
+ "NUMA node bigger than %d"), bit);
return -1;
}
- nodemask_set(&mask, i);
+ nodemask_set(&mask, bit);
}
mode = numatune.memory.mode;
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 54f7715..a3353cc 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1672,7 +1672,7 @@ static void
virPCIDeviceListDispose(void *obj)
{
virPCIDeviceListPtr list = obj;
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
virPCIDeviceFree(list->devs[i]);
@@ -1780,7 +1780,7 @@ virPCIDeviceListDel(virPCIDeviceListPtr list,
int
virPCIDeviceListFindIndex(virPCIDeviceListPtr list, virPCIDevicePtr dev)
{
- int i;
+ size_t i;
for (i = 0; i < list->count; i++)
if (list->devs[i]->domain == dev->domain &&
@@ -1799,7 +1799,7 @@ virPCIDeviceListFindByIDs(virPCIDeviceListPtr list,
unsigned int slot,
unsigned int function)
{
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
if (list->devs[i]->domain == domain &&
@@ -1815,10 +1815,10 @@ virPCIDeviceListFindByIDs(virPCIDeviceListPtr list,
virPCIDevicePtr
virPCIDeviceListFind(virPCIDeviceListPtr list, virPCIDevicePtr dev)
{
- int i;
+ int idx;
- if ((i = virPCIDeviceListFindIndex(list, dev)) >= 0)
- return list->devs[i];
+ if ((idx = virPCIDeviceListFindIndex(list, dev)) >= 0)
+ return list->devs[idx];
else
return NULL;
}
@@ -2416,7 +2416,7 @@ virPCIGetVirtualFunctions(const char *sysfs_path,
unsigned int *num_virtual_functions)
{
int ret = -1;
- int i;
+ size_t i;
DIR *dir = NULL;
struct dirent *entry = NULL;
char *device_link = NULL;
diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index 0757966..6730d00 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -98,7 +98,7 @@ int virPortAllocatorAcquire(virPortAllocatorPtr pa,
unsigned short *port)
{
int ret = -1;
- int i;
+ size_t i;
int fd = -1;
*port = 0;
@@ -112,7 +112,7 @@ int virPortAllocatorAcquire(virPortAllocatorPtr pa,
if (virBitmapGetBit(pa->bitmap,
i - pa->start, &used) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to query port %d"), i);
+ _("Failed to query port %zu"), i);
goto cleanup;
}
@@ -138,7 +138,7 @@ int virPortAllocatorAcquire(virPortAllocatorPtr pa,
if (bind(fd, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
if (errno != EADDRINUSE) {
virReportSystemError(errno,
- _("Unable to bind to port %d"), i);
+ _("Unable to bind to port %zu"), i);
goto cleanup;
}
/* In use, try next */
@@ -148,7 +148,7 @@ int virPortAllocatorAcquire(virPortAllocatorPtr pa,
if (virBitmapSetBit(pa->bitmap,
i - pa->start) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Failed to reserve port %d"), i);
+ _("Failed to reserve port %zu"), i);
goto cleanup;
}
*port = i;
diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index bf61127..e049c53 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -262,7 +262,8 @@ int virProcessKill(pid_t pid, int sig)
int
virProcessKillPainfully(pid_t pid, bool force)
{
- int i, ret = -1;
+ size_t i;
+ int ret = -1;
const char *signame = "TERM";
VIR_DEBUG("vpid=%lld force=%d", (long long)pid, force);
@@ -322,7 +323,7 @@ cleanup:
int virProcessSetAffinity(pid_t pid, virBitmapPtr map)
{
- int i;
+ size_t i;
bool set = false;
# ifdef CPU_ALLOC
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
@@ -392,7 +393,7 @@ int virProcessGetAffinity(pid_t pid,
virBitmapPtr *map,
int maxcpu)
{
- int i;
+ size_t i;
# ifdef CPU_ALLOC
/* New method dynamically allocates cpu mask, allowing unlimted cpus */
int numcpus = 1024;
diff --git a/src/util/virscsi.c b/src/util/virscsi.c
index 4870307..e30ef3b 100644
--- a/src/util/virscsi.c
+++ b/src/util/virscsi.c
@@ -352,7 +352,7 @@ static void
virSCSIDeviceListDispose(void *obj)
{
virSCSIDeviceListPtr list = obj;
- int i;
+ size_t i;
for (i = 0; i < list->count; i++)
virSCSIDeviceFree(list->devs[i]);
@@ -401,7 +401,7 @@ virSCSIDeviceListSteal(virSCSIDeviceListPtr list,
virSCSIDevicePtr dev)
{
virSCSIDevicePtr ret = NULL;
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
if (list->devs[i]->adapter != dev->adapter ||
@@ -439,7 +439,7 @@ virSCSIDevicePtr
virSCSIDeviceListFind(virSCSIDeviceListPtr list,
virSCSIDevicePtr dev)
{
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
if (list->devs[i]->adapter == dev->adapter &&
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 80b5c0b..525f599 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -42,7 +42,7 @@ typedef virSocketAddrIPv6 *virSocketAddrIPv6Ptr;
static int virSocketAddrGetIPv4Addr(virSocketAddrPtr addr, virSocketAddrIPv4Ptr tab) {
unsigned long val;
- int i;
+ size_t i;
if ((addr == NULL) || (tab == NULL) || (addr->data.stor.ss_family != AF_INET))
return -1;
@@ -58,7 +58,7 @@ static int virSocketAddrGetIPv4Addr(virSocketAddrPtr addr,
virSocketAddrIPv4Ptr
}
static int virSocketAddrGetIPv6Addr(virSocketAddrPtr addr, virSocketAddrIPv6Ptr tab) {
- int i;
+ size_t i;
if ((addr == NULL) || (tab == NULL) || (addr->data.stor.ss_family != AF_INET6))
return -1;
@@ -420,11 +420,11 @@ virSocketAddrMask(const virSocketAddrPtr addr,
return 0;
}
if (addr->data.stor.ss_family == AF_INET6) {
- int ii;
- for (ii = 0; ii < 16; ii++) {
- network->data.inet6.sin6_addr.s6_addr[ii]
- = (addr->data.inet6.sin6_addr.s6_addr[ii]
- & netmask->data.inet6.sin6_addr.s6_addr[ii]);
+ size_t i;
+ for (i = 0; i < 16; i++) {
+ network->data.inet6.sin6_addr.s6_addr[i]
+ = (addr->data.inet6.sin6_addr.s6_addr[i]
+ & netmask->data.inet6.sin6_addr.s6_addr[i]);
}
network->data.inet6.sin6_port = 0;
network->data.stor.ss_family = AF_INET6;
@@ -531,7 +531,7 @@ virSocketAddrBroadcastByPrefix(const virSocketAddrPtr addr,
*/
int virSocketAddrCheckNetmask(virSocketAddrPtr addr1, virSocketAddrPtr addr2,
virSocketAddrPtr netmask) {
- int i;
+ size_t i;
if ((addr1 == NULL) || (addr2 == NULL) || (netmask == NULL))
return -1;
@@ -642,7 +642,7 @@ int virSocketAddrGetRange(virSocketAddrPtr start, virSocketAddrPtr
end) {
*/
int virSocketAddrGetNumNetmaskBits(const virSocketAddrPtr netmask)
{
- int i, j;
+ size_t i, j;
int c = 0;
if (netmask->data.stor.ss_family == AF_INET) {
@@ -750,24 +750,24 @@ virSocketAddrPrefixToNetmask(unsigned int prefix,
result = 0;
} else if (family == AF_INET6) {
- int ii = 0;
+ size_t i = 0;
if (prefix > 128)
goto error;
while (prefix >= 8) {
/* do as much as possible an entire byte at a time */
- netmask->data.inet6.sin6_addr.s6_addr[ii++] = 0xff;
+ netmask->data.inet6.sin6_addr.s6_addr[i++] = 0xff;
prefix -= 8;
}
if (prefix > 0) {
/* final partial byte */
- netmask->data.inet6.sin6_addr.s6_addr[ii++]
+ netmask->data.inet6.sin6_addr.s6_addr[i++]
= ~((1 << (8 - prefix)) -1);
}
- while (ii < 16) {
+ while (i < 16) {
/* zerofill remainder in case it wasn't initialized */
- netmask->data.inet6.sin6_addr.s6_addr[ii++] = 0;
+ netmask->data.inet6.sin6_addr.s6_addr[i++] = 0;
}
netmask->data.stor.ss_family = AF_INET6;
result = 0;
diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 27aa4fe..0cf64c7 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -638,7 +638,8 @@ virStorageFileMatchesVersion(int format,
unsigned char *buf,
size_t buflen)
{
- int version, i;
+ int version;
+ size_t i;
/* Validate version number info */
if (fileTypeInfo[format].versionOffset == -1)
@@ -683,7 +684,7 @@ virStorageFileProbeFormatFromBuf(const char *path,
size_t buflen)
{
int format = VIR_STORAGE_FILE_RAW;
- int i;
+ size_t i;
int possibleFormat = VIR_STORAGE_FILE_RAW;
VIR_DEBUG("path=%s", path);
@@ -727,7 +728,7 @@ qcow2GetFeatures(virBitmapPtr *features,
int version = -1;
virBitmapPtr feat = NULL;
uint64_t bits;
- int i;
+ size_t i;
version = virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset);
diff --git a/src/util/virstring.c b/src/util/virstring.c
index 1937f82..dd884f5 100644
--- a/src/util/virstring.c
+++ b/src/util/virstring.c
@@ -490,7 +490,8 @@ virSkipSpacesBackwards(const char *str, char **endp)
char *
virArgvToString(const char *const *argv)
{
- int len, i;
+ int len;
+ size_t i;
char *ret, *p;
for (len = 1, i = 0; argv[i]; i++)
diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c
index c6d3a71..846f553 100644
--- a/src/util/virsysinfo.c
+++ b/src/util/virsysinfo.c
@@ -73,7 +73,7 @@ void virSysinfoSetup(const char *dmidecode, const char *sysinfo,
void virSysinfoDefFree(virSysinfoDefPtr def)
{
- int i;
+ size_t i;
if (def == NULL)
return;
@@ -926,7 +926,7 @@ virSysinfoSystemFormat(virBufferPtr buf, virSysinfoDefPtr def)
static void
virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def)
{
- int i;
+ size_t i;
virSysinfoProcessorDefPtr processor;
for (i = 0; i < def->nprocessor; i++) {
@@ -978,7 +978,7 @@ virSysinfoProcessorFormat(virBufferPtr buf, virSysinfoDefPtr def)
static void
virSysinfoMemoryFormat(virBufferPtr buf, virSysinfoDefPtr def)
{
- int i;
+ size_t i;
virSysinfoMemoryDefPtr memory;
for (i = 0; i < def->nmemory; i++) {
diff --git a/src/util/virthreadwin32.c b/src/util/virthreadwin32.c
index 4feaae9..8928414 100644
--- a/src/util/virthreadwin32.c
+++ b/src/util/virthreadwin32.c
@@ -33,7 +33,7 @@ typedef struct virThreadLocalData virThreadLocalData;
typedef virThreadLocalData *virThreadLocalDataPtr;
virMutex virThreadLocalLock;
-unsigned int virThreadLocalCount = 0;
+size_t virThreadLocalCount = 0;
virThreadLocalDataPtr virThreadLocalList = NULL;
DWORD selfkey;
@@ -54,7 +54,7 @@ int virThreadInitialize(void)
void virThreadOnExit(void)
{
- unsigned int i;
+ size_t i;
virMutexLock(&virThreadLocalLock);
for (i = 0; i < virThreadLocalCount; i++) {
if (virThreadLocalList[i].cleanup) {
@@ -219,7 +219,7 @@ void virCondBroadcast(virCondPtr c)
virMutexLock(&c->lock);
if (c->nwaiters) {
- unsigned int i;
+ size_t i;
for (i = 0; i < c->nwaiters; i++) {
HANDLE event = c->waiters[i];
SetEvent(event);
diff --git a/src/util/virthreadwin32.h b/src/util/virthreadwin32.h
index fc12847..645031b 100644
--- a/src/util/virthreadwin32.h
+++ b/src/util/virthreadwin32.h
@@ -32,7 +32,7 @@ struct virMutex {
struct virCond {
virMutex lock;
- unsigned int nwaiters;
+ size_t nwaiters;
HANDLE *waiters;
};
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index c767e32..f70ff46 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -51,7 +51,7 @@ virTypedParamsValidate(virTypedParameterPtr params, int nparams, ...)
{
va_list ap;
int ret = -1;
- int i, j;
+ size_t i, j;
const char *name;
int type;
@@ -117,7 +117,7 @@ virTypedParamsCheck(virTypedParameterPtr params,
const char **names,
int nnames)
{
- int i, j;
+ size_t i, j;
for (i = 0; i < nparams; i++) {
bool found = false;
@@ -400,7 +400,7 @@ virTypedParamsCopy(virTypedParameterPtr *dst,
virTypedParameterPtr src,
int nparams)
{
- int i;
+ size_t i;
*dst = NULL;
if (!src || nparams <= 0)
@@ -446,7 +446,7 @@ virTypedParamsGet(virTypedParameterPtr params,
int nparams,
const char *name)
{
- int i;
+ size_t i;
virResetLastError();
@@ -1163,7 +1163,7 @@ void
virTypedParamsClear(virTypedParameterPtr params,
int nparams)
{
- int i;
+ size_t i;
if (!params)
return;
diff --git a/src/util/viruri.c b/src/util/viruri.c
index 9cdb134..f7e2729 100644
--- a/src/util/viruri.c
+++ b/src/util/viruri.c
@@ -280,7 +280,7 @@ cleanup:
char *virURIFormatParams(virURIPtr uri)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
- int i;
+ size_t i;
bool amp = false;
for (i = 0; i < uri->paramsCount; ++i) {
diff --git a/src/util/virusb.c b/src/util/virusb.c
index d34e44f..e4acb4a 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -437,7 +437,7 @@ static void
virUSBDeviceListDispose(void *obj)
{
virUSBDeviceListPtr list = obj;
- int i;
+ size_t i;
for (i = 0; i < list->count; i++)
virUSBDeviceFree(list->devs[i]);
@@ -488,7 +488,7 @@ virUSBDeviceListSteal(virUSBDeviceListPtr list,
virUSBDevicePtr dev)
{
virUSBDevicePtr ret = NULL;
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
if (list->devs[i]->bus != dev->bus ||
@@ -523,7 +523,7 @@ virUSBDevicePtr
virUSBDeviceListFind(virUSBDeviceListPtr list,
virUSBDevicePtr dev)
{
- int i;
+ size_t i;
for (i = 0; i < list->count; i++) {
if (list->devs[i]->bus == dev->bus &&
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 569d035..60818a3 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -135,7 +135,7 @@ virPipeReadUntilEOF(int outfd, int errfd,
char **outbuf, char **errbuf) {
struct pollfd fds[2];
- int i;
+ size_t i;
bool finished[2];
fds[0].fd = outfd;
@@ -382,7 +382,7 @@ int virEnumFromString(const char *const*types,
unsigned int ntypes,
const char *type)
{
- unsigned int i;
+ size_t i;
if (!type)
return -1;
@@ -505,7 +505,7 @@ int virDiskNameToIndex(const char *name) {
const char *ptr = NULL;
int idx = 0;
static char const* const drive_prefix[] = {"fd", "hd",
"vd", "sd", "xvd", "ubd"};
- unsigned int i;
+ size_t i;
for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
if (STRPREFIX(name, drive_prefix[i])) {
@@ -537,7 +537,9 @@ int virDiskNameToIndex(const char *name) {
char *virIndexToDiskName(int idx, const char *prefix)
{
char *name = NULL;
- int i, k, offset;
+ size_t i;
+ int ctr;
+ int offset;
if (idx < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -545,7 +547,7 @@ char *virIndexToDiskName(int idx, const char *prefix)
return NULL;
}
- for (i = 0, k = idx; k >= 0; ++i, k = k / 26 - 1) { }
+ for (i = 0, ctr = idx; ctr >= 0; ++i, ctr = ctr / 26 - 1) { }
offset = strlen(prefix);
@@ -557,8 +559,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
strcpy(name, prefix);
name[offset + i] = '\0';
- for (i = i - 1, k = idx; k >= 0; --i, k = k / 26 - 1) {
- name[offset + i] = 'a' + (k % 26);
+ for (i = i - 1, ctr = idx; ctr >= 0; --i, ctr = ctr / 26 - 1) {
+ name[offset + i] = 'a' + (ctr % 26);
}
return name;
@@ -1294,7 +1296,8 @@ int
virSetUIDGIDWithCaps(uid_t uid, gid_t gid, unsigned long long capBits,
bool clearExistingCaps)
{
- int ii, capng_ret, ret = -1;
+ size_t i;
+ int capng_ret, ret = -1;
bool need_setgid = false, need_setuid = false;
bool need_setpcap = false;
@@ -1307,12 +1310,12 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, unsigned long long
capBits,
if (clearExistingCaps || (uid != (uid_t)-1 && uid != 0))
capng_clear(CAPNG_SELECT_BOTH);
- for (ii = 0; ii <= CAP_LAST_CAP; ii++) {
- if (capBits & (1ULL << ii)) {
+ for (i = 0; i <= CAP_LAST_CAP; i++) {
+ if (capBits & (1ULL << i)) {
capng_update(CAPNG_ADD,
CAPNG_EFFECTIVE|CAPNG_INHERITABLE|
CAPNG_PERMITTED|CAPNG_BOUNDING_SET,
- ii);
+ i);
}
}
@@ -1463,7 +1466,7 @@ bool virIsDevMapperDevice(const char *dev_name ATTRIBUTE_UNUSED)
bool
virValidateWWN(const char *wwn) {
- int i;
+ size_t i;
const char *p = wwn;
if (STRPREFIX(wwn, "0x")) {
@@ -1487,7 +1490,7 @@ virValidateWWN(const char *wwn) {
bool
virStrIsPrint(const char *str)
{
- int i;
+ size_t i;
for (i = 0; str[i]; i++)
if (!c_isprint(str[i]))
diff --git a/src/util/viruuid.c b/src/util/viruuid.c
index 9f4bb13..c5fa9a8 100644
--- a/src/util/viruuid.c
+++ b/src/util/viruuid.c
@@ -149,7 +149,7 @@ virUUIDGenerate(unsigned char *uuid)
int
virUUIDParse(const char *uuidstr, unsigned char *uuid) {
const char *cur;
- int i;
+ size_t i;
/*
* do a liberal scan allowing '-' and ' ' anywhere between character
@@ -233,7 +233,8 @@ virUUIDFormat(const unsigned char *uuid, char *uuidstr)
int
virUUIDIsValid(unsigned char *uuid)
{
- unsigned int i, ctr = 1;
+ size_t i;
+ unsigned int ctr = 1;
unsigned char c;
if (!uuid)
@@ -251,7 +252,7 @@ virUUIDIsValid(unsigned char *uuid)
static int
getDMISystemUUID(char *uuid, int len)
{
- unsigned int i = 0;
+ size_t i = 0;
const char *paths[] = {
"/sys/devices/virtual/dmi/id/product_uuid",
"/sys/class/dmi/id/product_uuid",
--
1.8.1.4