From c8badb79df2ef3bedbf455d7eddb1706041466b5 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Tue, 1 Feb 2011 19:23:14 +0000 Subject: [PATCH] Don't instantiate variables in for loops; we don't assume C99 compilers. This commit was SVN r24330. --- opal/mca/paffinity/hwloc/hwloc/src/topology-linux.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/opal/mca/paffinity/hwloc/hwloc/src/topology-linux.c b/opal/mca/paffinity/hwloc/hwloc/src/topology-linux.c index 135068c65c..4e82f5e65a 100644 --- a/opal/mca/paffinity/hwloc/hwloc/src/topology-linux.c +++ b/opal/mca/paffinity/hwloc/hwloc/src/topology-linux.c @@ -1974,10 +1974,11 @@ static int look_powerpc_device_tree_discover_cache(device_tree_cpus_t *cpus, uint32_t ibm_phandle, unsigned int *level, hwloc_bitmap_t cpuset) { + unsigned int i; int ret = -1; if ((NULL == level) || (NULL == cpuset)) return ret; - for (unsigned int i = 0; i < cpus->n; ++i) { + for (i = 0; i < cpus->n; ++i) { if (ibm_phandle != cpus->p[i].l2_cache) continue; if (NULL != cpus->p[i].cpuset) { @@ -2033,6 +2034,7 @@ look_powerpc_device_tree(struct hwloc_topology *topology) { device_tree_cpus_t cpus = { .n = 0, .p = NULL, .allocated = 0 }; const char ofroot[] = "/proc/device-tree/cpus"; + unsigned int i; int root_fd = topology->backend_params.sysfs.root_fd; DIR *dt = hwloc_opendir(ofroot, root_fd); @@ -2074,8 +2076,9 @@ look_powerpc_device_tree(struct hwloc_topology *topology) uint32_t nthreads = cb / sizeof(threads[0]); if (NULL != threads) { + unsigned int i; cpuset = hwloc_bitmap_alloc(); - for (unsigned int i = 0; i < nthreads; ++i) { + for (i = 0; i < nthreads; ++i) { hwloc_bitmap_set(cpuset, ntohl(threads[i])); } free(threads); @@ -2111,7 +2114,7 @@ look_powerpc_device_tree(struct hwloc_topology *topology) } #ifdef HWLOC_DEBUG - for (unsigned int i = 0; i < cpus.n; ++i) { + for (i = 0; i < cpus.n; ++i) { hwloc_debug("%i: %s ibm,phandle=%08X l2_cache=%08X ", i, cpus.p[i].name, cpus.p[i].ibm_phandle, cpus.p[i].l2_cache); if (NULL == cpus.p[i].cpuset) { @@ -2123,7 +2126,7 @@ look_powerpc_device_tree(struct hwloc_topology *topology) #endif /* Scan L2/L3/... caches */ - for (unsigned int i = 0; i < cpus.n; ++i) { + for (i = 0; i < cpus.n; ++i) { /* Skip real CPUs */ if (NULL != cpus.p[i].cpuset) continue; @@ -2143,7 +2146,7 @@ look_powerpc_device_tree(struct hwloc_topology *topology) } /* Do cleanup */ - for (unsigned int i = 0; i < cpus.n; ++i) { + for (i = 0; i < cpus.n; ++i) { hwloc_bitmap_free(cpus.p[i].cpuset); free(cpus.p[i].name); }