Skip to content

Commit a51a1f9

Browse files
author
ndenoyelle
committed
fix visualstudio build 8
1 parent c8c41f7 commit a51a1f9

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

utils/hwloc/hwloc-distrib.c

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ static hwloc_obj_type_t parse_policy_type(const char* type){
7272

7373
// Parse string in arg_types after topology create, load, filter etc...
7474
static void parse_policy(void){
75+
size_t i;
76+
char *type;
77+
7578
if (policy == ROUND_ROBIN){
7679
num_types = 1;
7780
policy_types = malloc(sizeof(*policy_types));
@@ -83,9 +86,6 @@ static void parse_policy(void){
8386
*policy_types = parse_policy_type(arg_types);
8487
}
8588
else {
86-
size_t i;
87-
char *type;
88-
8989
for(i=0; i<strlen(arg_types); i++)
9090
if (arg_types[i] == ':')
9191
num_types++;
@@ -104,19 +104,27 @@ int main(int argc, char *argv[])
104104
{
105105
long n = -1;
106106
char *input = NULL;
107+
char *restrictstring = NULL;
108+
char *str=NULL;
107109
enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT;
108110
int taskset = 0;
109111
int singlify = 0;
110112
int logical_index = 0;
111113
int physical_index = 0;
112114
int verbose = 0;
113-
char *restrictstring = NULL;
115+
int continue_it = 1;
114116
int from_index = -1;
115-
unsigned long flags = 0;
116-
unsigned long dflags = 0;
117117
int opt;
118118
int err;
119-
119+
unsigned long flags = 0;
120+
unsigned long dflags = 0;
121+
unsigned last;
122+
struct hwloc_distrib_iterator *it;
123+
hwloc_obj_type_t type;
124+
hwloc_bitmap_t cpuset;
125+
hwloc_bitmap_t restrictset;
126+
hwloc_obj_t root, next;
127+
120128
callname = argv[0];
121129
hwloc_utils_check_api_version(callname);
122130

@@ -207,7 +215,6 @@ int main(int argc, char *argv[])
207215
goto next;
208216
}
209217
else if (!strcmp (argv[0], "--ignore")) {
210-
hwloc_obj_type_t type;
211218
if (argc < 2) {
212219
usage(callname, stdout);
213220
exit(EXIT_FAILURE);
@@ -273,12 +280,8 @@ int main(int argc, char *argv[])
273280
argv++;
274281
}
275282

276-
{
277-
hwloc_bitmap_t cpuset = hwloc_bitmap_alloc();
278-
struct hwloc_distrib_iterator *it;
279-
hwloc_obj_t root, next=NULL;
280-
281-
if (input) {
283+
cpuset = hwloc_bitmap_alloc();
284+
if (input) {
282285
err = hwloc_utils_enable_input_format(topology, flags, input, &input_format, verbose, callname);
283286
if (err) {
284287
free(cpuset);
@@ -288,12 +291,12 @@ int main(int argc, char *argv[])
288291
hwloc_topology_set_flags(topology, flags);
289292
err = hwloc_topology_load(topology);
290293
if (err < 0) {
291-
free(cpuset);
294+
hwloc_bitmap_free(cpuset);
292295
return EXIT_FAILURE;
293296
}
294297

295298
if (restrictstring) {
296-
hwloc_bitmap_t restrictset = hwloc_bitmap_alloc();
299+
restrictset = hwloc_bitmap_alloc();
297300
hwloc_bitmap_sscanf(restrictset, restrictstring);
298301
err = hwloc_topology_restrict (topology, restrictset, 0);
299302
if (err) {
@@ -322,21 +325,18 @@ int main(int argc, char *argv[])
322325
return EXIT_FAILURE;
323326

324327
// Go to start index.
325-
while ( hwloc_distrib_iterator_next(topology, it, &next) &&
326-
from_index > 0 && next->logical_index != from_index );
328+
while ( hwloc_distrib_iterator_next(topology, it, &next) && from_index > 0 && next->logical_index != from_index );
327329

328-
int continue_it = 1;
329330
do {
330331
if (logical_index) {
331332
printf("%d\n", next->logical_index);
332333
} else if (physical_index){
333334
printf("%d\n", next->os_index);
334335
} else {
335336
hwloc_bitmap_copy(cpuset, next->cpuset);
336-
char *str = NULL;
337337
if (singlify) {
338338
if (dflags & HWLOC_DISTRIB_FLAG_REVERSE) {
339-
unsigned last = hwloc_bitmap_last(cpuset);
339+
last = hwloc_bitmap_last(cpuset);
340340
hwloc_bitmap_only(cpuset, last);
341341
} else {
342342
hwloc_bitmap_singlify(cpuset);
@@ -352,11 +352,10 @@ int main(int argc, char *argv[])
352352
if ((! continue_it && n < 0) || --n == 0)
353353
break;
354354
continue_it = hwloc_distrib_iterator_next(topology, it, &next);
355-
} while (1);
356-
hwloc_bitmap_free(cpuset);
357-
hwloc_distrib_destroy_iterator(it);
358-
free(policy_types);
359-
}
355+
} while (1);
356+
hwloc_bitmap_free(cpuset);
357+
hwloc_distrib_destroy_iterator(it);
358+
free(policy_types);
360359

361360
hwloc_topology_destroy(topology);
362361

0 commit comments

Comments
 (0)