]> granicus.if.org Git - graphviz/commitdiff
represent route array lengths as size_t
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 8 Apr 2021 03:58:25 +0000 (20:58 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 17 Apr 2021 21:02:40 +0000 (14:02 -0700)
This fixes one -Wsign-conversion warning, though introduces a -Wconversion
warning. We should be able to remove the latter as we continue cleaning up the
use of int for sizes.

lib/ortho/ortho.c
lib/ortho/structures.h

index b50240d92ab6d26565b90064d6422a5a1a7dab05..ed261cc3c51904e8c65dc3ad2db8ee5375229988 100644 (file)
@@ -144,7 +144,6 @@ convertSPtoRoute (sgraph* g, snode* fst, snode* lst)
     snode* ptr;
     snode* next;
     snode* prev;  /* node in shortest path just previous to next */
-    int i;
     size_t sz = 0;
     cell* cp;
     cell* ncp;
@@ -235,7 +234,7 @@ convertSPtoRoute (sgraph* g, snode* fst, snode* lst)
     }
 
     rte.segs = realloc (rte.segs, rte.n*sizeof(segment));
-    for (i=0; i<rte.n; i++) {
+    for (size_t i=0; i<rte.n; i++) {
        if (i > 0)
            rte.segs[i].prev = rte.segs + (i-1);
        if (i < rte.n-1)
@@ -444,11 +443,11 @@ static void
 assignSegs (int nrtes, route* route_list, maze* mp)
 {
     channel* chan;
-    int i, j;
+    int i;
 
     for (i=0;i<nrtes;i++) {
        route rte = route_list[i];
-       for (j=0;j<rte.n;j++) {
+       for (size_t j=0;j<rte.n;j++) {
            segment* seg = rte.segs+j;
            if (seg->isVert)
                chan = chanSearch(mp->vchans, seg);
@@ -1126,7 +1125,7 @@ static void
 attachOrthoEdges (Agraph_t* g, maze* mp, int n_edges, route* route_list, splineInfo *sinfo, epair_t es[], int doLbls)
 {
     int irte = 0;
-    int i, ipt, npts;
+    int ipt, npts;
     pointf* ispline = 0;
     int splsz = 0;
     pointf p, p1, q1;
@@ -1160,7 +1159,7 @@ attachOrthoEdges (Agraph_t* g, maze* mp, int n_edges, route* route_list, splineI
        ispline[0] = ispline[1] = p;
        ipt = 2;
 
-       for (i = 1;i<rte.n;i++) {
+       for (size_t i = 1;i<rte.n;i++) {
                seg = rte.segs+i;
                if (seg->isVert)
                    p.x = vtrack(seg, mp);
@@ -1428,7 +1427,7 @@ coordOf (cell* cp, snode* np)
 static boxf
 emitEdge (FILE* fp, Agedge_t* e, route rte, maze* m, int ix, boxf bb)
 {
-    int i, x, y;
+    int x, y;
     boxf n = CELL(agtail(e))->bb;
     segment* seg = rte.segs;
     if (seg->isVert) {
@@ -1445,7 +1444,7 @@ emitEdge (FILE* fp, Agedge_t* e, route rte, maze* m, int ix, boxf bb)
     bb.UR.y = MAX(bb.UR.y, SC*y);
     fprintf (fp, "newpath %d %d moveto\n", SC*x, SC*y);
 
-    for (i = 1;i<rte.n;i++) {
+    for (size_t i = 1;i<rte.n;i++) {
        seg = rte.segs+i;
        if (seg->isVert) {
            x = vtrack(seg, m);
index e3e0ea1a35e276d1f2391fd888337a574312d1ec..216b9c3b9fda9870f7989e6b5bb3b7f3bfaa3300 100644 (file)
@@ -14,6 +14,7 @@
 #include "types.h"
 #include "cgraph.h"
 #include <ortho/rawgraph.h>
+#include <stddef.h>
 
 typedef struct {
     double p1, p2;
@@ -45,7 +46,7 @@ typedef struct segment {
 } segment;
 
 typedef struct {
-  int n;
+  size_t n;
   segment* segs;
 } route;