1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-26 14:03:49 +03:00

Convert 'int i' to 'size_t i' in src/node_device/ 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 a1a1433ca0
commit 11f1e1009a
4 changed files with 27 additions and 22 deletions

View File

@ -129,7 +129,7 @@ nodeNumOfDevices(virConnectPtr conn,
{ {
virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData; virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
int ndevs = 0; int ndevs = 0;
unsigned int i; size_t i;
if (virNodeNumOfDevicesEnsureACL(conn) < 0) if (virNodeNumOfDevicesEnsureACL(conn) < 0)
return -1; return -1;
@ -159,7 +159,7 @@ nodeListDevices(virConnectPtr conn,
{ {
virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData; virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
int ndevs = 0; int ndevs = 0;
unsigned int i; size_t i;
if (virNodeListDevicesEnsureACL(conn) < 0) if (virNodeListDevicesEnsureACL(conn) < 0)
return -1; return -1;
@ -247,7 +247,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
const char *wwpn, const char *wwpn,
unsigned int flags) unsigned int flags)
{ {
unsigned int i; size_t i;
virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData; virNodeDeviceDriverStatePtr driver = conn->nodeDevicePrivateData;
virNodeDeviceObjListPtr devs = &driver->devs; virNodeDeviceObjListPtr devs = &driver->devs;
virNodeDevCapsDefPtr cap = NULL; virNodeDevCapsDefPtr cap = NULL;

View File

@ -408,7 +408,8 @@ gather_capabilities(LibHalContext *ctx, const char *udi,
char *bus_name = NULL; char *bus_name = NULL;
virNodeDevCapsDefPtr caps = NULL; virNodeDevCapsDefPtr caps = NULL;
char **hal_cap_names = NULL; char **hal_cap_names = NULL;
int rv, i; int rv;
size_t i;
if (STREQ(udi, "/org/freedesktop/Hal/devices/computer")) { if (STREQ(udi, "/org/freedesktop/Hal/devices/computer")) {
rv = gather_capability(ctx, udi, "system", &caps); rv = gather_capability(ctx, udi, "system", &caps);
@ -632,7 +633,8 @@ nodeStateInitialize(bool privileged ATTRIBUTE_UNUSED,
{ {
LibHalContext *hal_ctx = NULL; LibHalContext *hal_ctx = NULL;
char **udi = NULL; char **udi = NULL;
int num_devs, i; int num_devs;
size_t i;
int ret = -1; int ret = -1;
DBusConnection *sysbus; DBusConnection *sysbus;
DBusError err; DBusError err;
@ -750,7 +752,8 @@ nodeStateReload(void)
{ {
DBusError err; DBusError err;
char **udi = NULL; char **udi = NULL;
int num_devs, i; int num_devs;
size_t i;
LibHalContext *hal_ctx; LibHalContext *hal_ctx;
VIR_INFO("Reloading HAL device state"); VIR_INFO("Reloading HAL device state");

View File

@ -317,7 +317,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
virNodeDeviceDefPtr def, virNodeDeviceDefPtr def,
const char *s) const char *s)
{ {
int ret = 0, i = 0; int ret = 0;
size_t i;
virBuffer buf = VIR_BUFFER_INITIALIZER; virBuffer buf = VIR_BUFFER_INITIALIZER;
virBufferAsprintf(&buf, "%s_%s", virBufferAsprintf(&buf, "%s_%s",

View File

@ -155,7 +155,7 @@ virNodeCountThreadSiblings(const char *dir, unsigned int cpu)
char *path; char *path;
FILE *pathfp; FILE *pathfp;
char str[1024]; char str[1024];
int i; size_t i;
if (virAsprintf(&path, "%s/cpu%u/topology/thread_siblings", if (virAsprintf(&path, "%s/cpu%u/topology/thread_siblings",
dir, cpu) < 0) dir, cpu) < 0)
@ -217,7 +217,7 @@ virNodeParseSocket(const char *dir, unsigned int cpu)
static int static int
CPU_COUNT(cpu_set_t *set) CPU_COUNT(cpu_set_t *set)
{ {
int i, count = 0; size_t i, count = 0;
for (i = 0; i < CPU_SETSIZE; i++) for (i = 0; i < CPU_SETSIZE; i++)
if (CPU_ISSET(i, set)) if (CPU_ISSET(i, set))
@ -247,7 +247,7 @@ virNodeParseNode(const char *node,
int sock; int sock;
cpu_set_t *core_maps = NULL; cpu_set_t *core_maps = NULL;
int core; int core;
int i; size_t i;
int siblings; int siblings;
unsigned int cpu; unsigned int cpu;
int online; int online;
@ -623,7 +623,7 @@ int linuxNodeGetCPUStats(FILE *procstat,
char *buf = line; char *buf = line;
if (STRPREFIX(buf, cpu_header)) { /* aka logical CPU time */ if (STRPREFIX(buf, cpu_header)) { /* aka logical CPU time */
int i; size_t i;
if (sscanf(buf, if (sscanf(buf,
"%*s %llu %llu %llu %llu %llu" // user ~ iowait "%*s %llu %llu %llu %llu %llu" // user ~ iowait
@ -697,7 +697,7 @@ int linuxNodeGetMemoryStats(FILE *meminfo,
int *nparams) int *nparams)
{ {
int ret = -1; int ret = -1;
int i = 0, j = 0, k = 0; size_t i = 0, j = 0, k = 0;
int found = 0; int found = 0;
int nr_param; int nr_param;
char line[1024]; char line[1024];
@ -1025,16 +1025,17 @@ nodeGetCPUCount(void)
* will be consecutive. * will be consecutive.
*/ */
char *cpupath = NULL; char *cpupath = NULL;
int i = 0; int ncpu;
if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/present")) { if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/present")) {
i = linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present"); ncpu = linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present");
} else if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/cpu0")) { } else if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/cpu0")) {
ncpu = 0;
do { do {
i++; ncpu++;
VIR_FREE(cpupath); VIR_FREE(cpupath);
if (virAsprintf(&cpupath, "%s/cpu/cpu%d", if (virAsprintf(&cpupath, "%s/cpu/cpu%d",
SYSFS_SYSTEM_PATH, i) < 0) SYSFS_SYSTEM_PATH, ncpu) < 0)
return -1; return -1;
} while (virFileExists(cpupath)); } while (virFileExists(cpupath));
} else { } else {
@ -1045,7 +1046,7 @@ nodeGetCPUCount(void)
} }
VIR_FREE(cpupath); VIR_FREE(cpupath);
return i; return ncpu;
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
return freebsdNodeGetCPUCount(); return freebsdNodeGetCPUCount();
#else #else
@ -1069,7 +1070,7 @@ nodeGetCPUBitmap(int *max_id ATTRIBUTE_UNUSED)
if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/online")) { if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/online")) {
cpumap = linuxParseCPUmap(present, SYSFS_SYSTEM_PATH "/cpu/online"); cpumap = linuxParseCPUmap(present, SYSFS_SYSTEM_PATH "/cpu/online");
} else { } else {
int i; size_t i;
cpumap = virBitmapNew(present); cpumap = virBitmapNew(present);
if (!cpumap) if (!cpumap)
@ -1134,7 +1135,7 @@ nodeMemoryParametersIsAllSupported(virTypedParameterPtr params,
int nparams) int nparams)
{ {
char *path = NULL; char *path = NULL;
int i; size_t i;
for (i = 0; i < nparams; i++) { for (i = 0; i < nparams; i++) {
virTypedParameterPtr param = &params[i]; virTypedParameterPtr param = &params[i];
@ -1169,7 +1170,7 @@ nodeSetMemoryParameters(virTypedParameterPtr params ATTRIBUTE_UNUSED,
virCheckFlags(0, -1); virCheckFlags(0, -1);
#ifdef __linux__ #ifdef __linux__
int i; size_t i;
int rc; int rc;
if (virTypedParamsValidate(params, nparams, if (virTypedParamsValidate(params, nparams,
@ -1270,7 +1271,7 @@ nodeGetMemoryParameters(virTypedParameterPtr params ATTRIBUTE_UNUSED,
unsigned long long pages_unshared; unsigned long long pages_unshared;
unsigned long long pages_volatile; unsigned long long pages_volatile;
unsigned long long full_scans = 0; unsigned long long full_scans = 0;
int i; size_t i;
int ret; int ret;
if ((*nparams) == 0) { if ((*nparams) == 0) {
@ -1607,7 +1608,7 @@ nodeCapsInitNUMA(virCapsPtr caps)
memset(allonesmask, 0xff, mask_n_bytes); memset(allonesmask, 0xff, mask_n_bytes);
for (n = 0; n <= numa_max_node(); n++) { for (n = 0; n <= numa_max_node(); n++) {
int i; size_t i;
/* The first time this returns -1, ENOENT if node doesn't exist... */ /* The first time this returns -1, ENOENT if node doesn't exist... */
if (numa_node_to_cpus(n, mask, mask_n_bytes) < 0) { if (numa_node_to_cpus(n, mask, mask_n_bytes) < 0) {
VIR_WARN("NUMA topology for cell %d of %d not available, ignoring", VIR_WARN("NUMA topology for cell %d of %d not available, ignoring",