Skip to content

Commit 142d8cf

Browse files
committed
netloc: int -> unsigned int for utarray functions
Signed-off-by: Cyril Bordage <[email protected]>
1 parent ae902ef commit 142d8cf

File tree

8 files changed

+32
-33
lines changed

8 files changed

+32
-33
lines changed

include/netloc/utarray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ typedef struct {
218218
#define utarray_next(a,e) (((e)==NULL) ? utarray_front(a) : ((((a)->i) > (utarray_eltidx(a,e)+1)) ? _utarray_eltptr(a,utarray_eltidx(a,e)+1) : NULL))
219219
#define utarray_prev(a,e) (((e)==NULL) ? utarray_back(a) : ((utarray_eltidx(a,e) > 0) ? _utarray_eltptr(a,utarray_eltidx(a,e)-1) : NULL))
220220
#define utarray_back(a) (((a)->i) ? (_utarray_eltptr(a,(a)->i-1)) : NULL)
221-
#define utarray_eltidx(a,e) (((char*)(e) >= (char*)((a)->d)) ? (((char*)(e) - (char*)((a)->d))/(size_t)(a)->icd.sz) : -1)
221+
#define utarray_eltidx(a,e) (((char*)(e) >= (char*)((a)->d)) ? (((char*)(e) - (char*)((a)->d))/(size_t)(a)->icd.sz) : (unsigned int)-1)
222222

223223
/* last we pre-define a few icd for common utarrays of ints and strings */
224224
static void utarray_str_cpy(void *dst, const void *src) {

netloc/architecture.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void netloc_arch_tree_complete(netloc_arch_tree_t *tree, UT_array **down_degrees
4949
int *degrees = (int *)down_degrees_by_level[l]->d;
5050
int max_degree = max_degrees[l];
5151

52-
int down_level_idx = 0;
52+
unsigned int down_level_idx = 0;
5353
UT_array *down_level_degrees = down_degrees_by_level[l+1];
5454
int down_level_max_degree = max_degrees[l+1];
5555
for (int d = 0; d < num_degrees; d++) {
@@ -566,7 +566,7 @@ int partition_topology_to_tleaf(netloc_topology_t *topology,
566566
UT_array *new_nodes;
567567
utarray_new(new_nodes, &ut_ptr_icd);
568568

569-
for (int n = 0; n < utarray_len(nodes); n++) {
569+
for (unsigned int n = 0; n < utarray_len(nodes); n++) {
570570
netloc_node_t *node = *(void **)utarray_eltptr(nodes, n);
571571
netloc_analysis_data *node_data = (netloc_analysis_data *)node->userdata;
572572
/* There is a problem, this is not a tree */
@@ -804,8 +804,8 @@ int netloc_arch_build(netloc_arch_t *arch, int add_slots)
804804
if (!partition_name) {
805805
fprintf(stderr, "Error: you need to set NETLOC_PARTITION in your environment.\n");
806806
fprintf(stderr, "\tIt can be: ");
807-
int num_partitions = utarray_len(topology->partitions);
808-
for (int p = 0; p < num_partitions; p++) {
807+
unsigned int num_partitions = utarray_len(topology->partitions);
808+
for (unsigned int p = 0; p < num_partitions; p++) {
809809
char *partition = *(char **)utarray_eltptr(topology->partitions, p);
810810
fprintf(stderr, "%s%s", partition, p != num_partitions-1 ? ", ": "\n");
811811
}

netloc/edge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int netloc_edge_destruct(netloc_edge_t * edge)
6060
utarray_free(edge->physical_links);
6161
utarray_free(edge->partitions);
6262

63-
for (int e = 0; e < netloc_edge_get_num_subedges(edge); e++) {
63+
for (unsigned int e = 0; e < netloc_edge_get_num_subedges(edge); e++) {
6464
netloc_edge_t *subedge;
6565
subedge = netloc_edge_get_subedge(edge, e);
6666
netloc_edge_destruct(subedge);
@@ -77,7 +77,7 @@ void netloc_edge_reset_uid(void)
7777

7878
int netloc_edge_is_in_partition(netloc_edge_t *edge, int partition)
7979
{
80-
for (int i = 0; i < netloc_get_num_partitions(edge); i++) {
80+
for (unsigned int i = 0; i < netloc_get_num_partitions(edge); i++) {
8181
if (netloc_get_partition(edge, i) == partition)
8282
return 1;
8383
}

netloc/hwloc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int netloc_topology_read_hwloc(netloc_topology_t *topology, int num_nodes,
101101
}
102102

103103
/* Add the hwloc topology */
104-
int t = 0;
104+
unsigned int t = 0;
105105
while (t < utarray_len(hwloc_topo_names) &&
106106
strcmp(*(char **)utarray_eltptr(hwloc_topo_names, t), refname)) {
107107
t++;
@@ -164,7 +164,7 @@ int netloc_topology_read_hwloc(netloc_topology_t *topology, int num_nodes,
164164
topology->hwloc_topos = (hwloc_topology_t *)hwloc_topos->d;
165165

166166
printf("%d hwloc topologies found:\n", utarray_len(topology->topos));
167-
for (int p = 0; p < utarray_len(topology->topos); p++) {
167+
for (unsigned int p = 0; p < utarray_len(topology->topos); p++) {
168168
printf("\t'%s'\n", *(char **)utarray_eltptr(topology->topos, p));
169169
}
170170

@@ -228,7 +228,7 @@ int netloc_arch_node_get_hwloc_info(netloc_arch_node_t *arch_node)
228228
}
229229

230230
/* List of PUs */
231-
int max_os_index = 0;
231+
unsigned int max_os_index = 0;
232232
UT_array *ordered_host_array;
233233
int *ordered_hosts;
234234
utarray_new(ordered_host_array, &ut_int_icd);

netloc/node.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int node_or_subnode_destruct(netloc_node_t * node, int is_node)
7777
}
7878

7979
/* Subnodes */
80-
for (int n = 0; n < utarray_len(node->subnodes); n++) {
80+
for (unsigned int n = 0; n < utarray_len(node->subnodes); n++) {
8181
netloc_node_t *subnode = *(netloc_node_t **)
8282
utarray_eltptr(node->subnodes, n);
8383
node_or_subnode_destruct(subnode, 0);
@@ -119,7 +119,7 @@ char * netloc_node_pretty_print(netloc_node_t* node)
119119

120120
int netloc_node_is_in_partition(netloc_node_t *node, int partition)
121121
{
122-
for (int i = 0; i < netloc_get_num_partitions(node); i++) {
122+
for (unsigned int i = 0; i < netloc_get_num_partitions(node); i++) {
123123
if (netloc_get_partition(node, i) == partition)
124124
return 1;
125125
}

netloc/topology.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ int netloc_topology_destruct(netloc_topology_t *topology)
314314
}
315315

316316
/** Hwloc topology List */
317-
for (int t = 0; t < utarray_len(topology->topos); t++) {
317+
for (unsigned int t = 0; t < utarray_len(topology->topos); t++) {
318318
if (topology->hwloc_topos[t])
319319
hwloc_topology_destroy(topology->hwloc_topos[t]);
320320
}
@@ -334,7 +334,7 @@ int netloc_topology_find_partition_idx(netloc_topology_t *topology, char *partit
334334
return -1;
335335

336336
/* Find the selected partition in the topology */
337-
int p = 0;
337+
unsigned int p = 0;
338338
int found = 0;
339339
while (p < utarray_len(topology->partitions)) {
340340
char *current_name = *(char **)utarray_eltptr(topology->partitions, p);

utils/netloc/draw/netloc_draw_to_json.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static int handle_link(netloc_physical_link_t *link, json_t *json_links)
296296

297297
json_t *json_partitions = json_array_new();
298298

299-
for (int p = 0; p < netloc_get_num_partitions(link); p++)
299+
for (unsigned int p = 0; p < netloc_get_num_partitions(link); p++)
300300
{
301301
int partition = netloc_get_partition(link, p);
302302
json_array_add(json_partitions, json_int_new(partition));
@@ -324,7 +324,7 @@ static int handle_edge(netloc_edge_t *edge, json_t *json_edges)
324324

325325
/* Links */
326326
json_t *json_links = json_array_new();
327-
for (int l = 0; l < netloc_edge_get_num_links(edge); l++)
327+
for (unsigned int l = 0; l < netloc_edge_get_num_links(edge); l++)
328328
{
329329
netloc_physical_link_t *link = netloc_edge_get_link(edge, l);
330330
json_array_add(json_links, json_int_new(link->id));
@@ -333,7 +333,7 @@ static int handle_edge(netloc_edge_t *edge, json_t *json_edges)
333333

334334
/* Partition list */
335335
json_t *json_partitions = json_array_new();
336-
for (int p = 0; p < netloc_get_num_partitions(edge); p++)
336+
for (unsigned int p = 0; p < netloc_get_num_partitions(edge); p++)
337337
{
338338
int partition = netloc_get_partition(edge, p);
339339
json_array_add(json_partitions, json_int_new(partition));
@@ -342,7 +342,7 @@ static int handle_edge(netloc_edge_t *edge, json_t *json_edges)
342342

343343
/* Subnode edges */
344344
json_t *json_subedges = json_array_new();
345-
for (int s = 0; s < netloc_edge_get_num_subedges(edge); s++)
345+
for (unsigned int s = 0; s < netloc_edge_get_num_subedges(edge); s++)
346346
{
347347
netloc_edge_t *subedge = netloc_edge_get_subedge(edge, s);
348348
json_array_add(json_subedges, json_int_new(subedge->id));
@@ -372,7 +372,7 @@ static int handle_node(netloc_node_t *node, json_t *json_nodes,
372372

373373
/* Subnodes */
374374
json_t *json_subnodes = json_array_new();
375-
for (int s = 0; s < netloc_node_get_num_subnodes(node); s++)
375+
for (unsigned int s = 0; s < netloc_node_get_num_subnodes(node); s++)
376376
{
377377
netloc_node_t *subnode = netloc_node_get_subnode(node, s);
378378
handle_node(subnode, json_nodes, json_edges, 1);
@@ -391,7 +391,7 @@ static int handle_node(netloc_node_t *node, json_t *json_nodes,
391391

392392
/* Partitions */
393393
json_t *json_partitions = json_array_new();
394-
for (int p = 0; p < netloc_get_num_partitions(node); p++)
394+
for (unsigned int p = 0; p < netloc_get_num_partitions(node); p++)
395395
{
396396
int partition = netloc_get_partition(node, p);
397397
json_array_add(json_partitions, json_int_new(partition));

utils/netloc/infiniband/netloc_ib_extract_dats.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ node_t *get_node(node_t **nodes, char *type, char *lid,
188188
static int find_other_physical_link(physical_link_t *link)
189189
{
190190
node_t *dest = link->dest;
191-
int dest_port = link->ports[1];
191+
unsigned int dest_port = link->ports[1];
192192

193193
physical_link_t *other_link = (physical_link_t *)
194194
utarray_eltptr(dest->physical_links, dest_port-1);
@@ -288,7 +288,7 @@ int build_paths(void)
288288
break;
289289
}
290290

291-
int port = route_dest->port;
291+
unsigned int port = route_dest->port;
292292
link = (physical_link_t *)
293293
utarray_eltptr(node_cur->physical_links, port-1);
294294
utarray_push_back(found_links, &link);
@@ -431,7 +431,7 @@ int netloc_topology_set_partitions(void)
431431
if (node_dest->main_partition != partition)
432432
continue;
433433

434-
for (int l = 0; l < utarray_len(path_dest->links); l++) {
434+
for (unsigned int l = 0; l < utarray_len(path_dest->links); l++) {
435435
physical_link_t *link = *(physical_link_t **)
436436
utarray_eltptr(path_dest->links, l);
437437
if (!link->partitions) {
@@ -605,7 +605,7 @@ int main(int argc, char **argv)
605605
free(node->partitions);
606606

607607
/* Physical links */
608-
for (int l = 0; l < utarray_len(node->physical_links); l++) {
608+
for (unsigned int l = 0; l < utarray_len(node->physical_links); l++) {
609609
physical_link_t *link = (physical_link_t *)
610610
utarray_eltptr(node->physical_links, l);
611611
free(link->width);
@@ -830,7 +830,7 @@ int read_discover(char *subnet, char *path, char *filename)
830830
link->parent_node = src_node;
831831
link->other_id = -1;
832832

833-
int port_idx = link->ports[0]-1;
833+
unsigned int port_idx = link->ports[0]-1;
834834
/* NB: there is no function to set a specific index */
835835
if (port_idx+1 > utarray_len(src_node->physical_links)) {
836836
utarray_insert(src_node->physical_links, link, port_idx);
@@ -878,8 +878,8 @@ int read_discover(char *subnet, char *path, char *filename)
878878
/* Find the link in the other way */
879879
node_t *node, *node_tmp;
880880
HASH_ITER(hh, nodes, node, node_tmp) {
881-
int num_links = utarray_len(node->physical_links);
882-
for (int i = 0; i < num_links; i++) {
881+
unsigned int num_links = utarray_len(node->physical_links);
882+
for (unsigned int i = 0; i < num_links; i++) {
883883
physical_link_t *link = (physical_link_t *)
884884
utarray_eltptr(node->physical_links, i);
885885
if (!link->dest)
@@ -902,7 +902,6 @@ char *partition_list_to_string(int *partition_list)
902902
char tmp[20];
903903
int max_length = num_partitions*(sprintf(tmp, "%d", num_partitions)+1)+1;
904904

905-
906905
char *string = (char *)malloc(max_length*sizeof(char));
907906
string[0] = '\0';
908907
for (int p = 0; p < num_partitions; p++) {
@@ -953,15 +952,15 @@ int write_into_file(char *subnet, char *path, char *hwlocpath)
953952
edge_t *edge, *edge_tmp;
954953
fprintf(output, "%s", node->physical_id);
955954
HASH_ITER(hh, node->edges, edge, edge_tmp) {
956-
int num_links = utarray_len(edge->physical_link_idx);
955+
unsigned int num_links = utarray_len(edge->physical_link_idx);
957956
fprintf(output, ",%s,", edge->dest);
958957
fprintf(output, "%f,", edge->total_gbits);
959958
char *partition_str = partition_list_to_string(edge->partitions);
960959
fprintf(output, "%s,", partition_str);
961960
free(partition_str);
962-
fprintf(output, "%d,", num_links);
963-
for (int l = 0; l < num_links; l++) {
964-
int link_idx = *(int *)utarray_eltptr(edge->physical_link_idx, l);
961+
fprintf(output, "%u,", num_links);
962+
for (unsigned int l = 0; l < num_links; l++) {
963+
unsigned int link_idx = *(int *)utarray_eltptr(edge->physical_link_idx, l);
965964
physical_link_t *link = (physical_link_t *)
966965
utarray_eltptr(node->physical_links, link_idx);
967966
fprintf(output, "%d,", link->int_id);
@@ -998,7 +997,7 @@ int write_into_file(char *subnet, char *path, char *hwlocpath)
998997
node_t *node_dest = path_dest->node;
999998
fprintf(output, "%s,%s",
1000999
node_src->physical_id, node_dest->physical_id);
1001-
for (int l = 0; l < utarray_len(path_dest->links); l++) {
1000+
for (unsigned int l = 0; l < utarray_len(path_dest->links); l++) {
10021001
physical_link_t *link = *(physical_link_t **)
10031002
utarray_eltptr(path_dest->links, l);
10041003
fprintf(output, ",%d", link->int_id);

0 commit comments

Comments
 (0)