]> granicus.if.org Git - graphviz/commitdiff
dotgen: remove shadowing of 'n' in 'build_ranks'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 8 May 2022 20:47:20 +0000 (13:47 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 27 May 2022 04:54:40 +0000 (21:54 -0700)
The compiler was warning:

  mincross.c:1404:17: warning: declaration of 'n' shadows a previous local
    [-Wshadow]
   1404 |             int n, ndiv2;
        |                 ^
  mincross.c:1359:13: note: shadowed declaration is here
   1359 |     node_t *n, *n0;
        |             ^

We can trivially rephrase the code to avoid this noise.

lib/dotgen/mincross.c

index 0e6a45835b3c4675639d8a989524087c90ee3746..943cac615fdd3cdf6be58062e4cc97b08e21cc07 100644 (file)
@@ -1401,12 +1401,11 @@ void build_ranks(graph_t * g, int pass)
     for (i = GD_minrank(g); i <= GD_maxrank(g); i++) {
        GD_rank(Root)[i].valid = false;
        if (GD_flip(g) && GD_rank(g)[i].n > 0) {
-           int n, ndiv2;
            node_t **vlist = GD_rank(g)[i].v;
-           n = GD_rank(g)[i].n - 1;
-           ndiv2 = n / 2;
-           for (j = 0; j <= ndiv2; j++)
-               exchange(vlist[j], vlist[n - j]);
+           int num_nodes_1 = GD_rank(g)[i].n - 1;
+           int half_num_nodes_1 = num_nodes_1 / 2;
+           for (j = 0; j <= half_num_nodes_1; j++)
+               exchange(vlist[j], vlist[num_nodes_1 - j]);
        }
     }