]> granicus.if.org Git - graphviz/commitdiff
mkSurface/get_triangles: fix mismatch of calling convention in 'cntFace'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 20:01:23 +0000 (12:01 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 10 Nov 2021 02:34:09 +0000 (18:34 -0800)
The compiler said about this code:

  delaunay.c:477:34: warning: cast between incompatible function types from
    ‘void (*)(GFace *, int *)’ {aka ‘void (*)(struct <anonymous> *, int *)’} to
    ‘gint (*)(void *, void *)’ {aka ‘int (*)(void *, void *)’}
    [-Wcast-function-type]
       gts_surface_foreach_face (s, (GtsFunc) cntFace, &nfaces);
                                    ^

Similar to the prior commit, this was relying on a coincident return value of 0
from the callback function.

lib/neatogen/delaunay.c

index f68819e03502f00cda0462d0d36d932729b9ef39..08805abdc9cfcbf693a709327a629699af91fd24 100644 (file)
@@ -398,10 +398,14 @@ int *delaunay_tri(double *x, double *y, int n, int* pnedges)
     return edges;
 }
 
-static void cntFace (GFace* fp, int* ip)
-{
+static gint cntFace(void *face, void *data) {
+    GFace *fp = face;
+    int *ip = data;
+
     fp->idx = *ip;
     *ip += 1;
+
+    return 0;
 }
 
 typedef struct {
@@ -489,7 +493,7 @@ mkSurface (double *x, double *y, int n, int* segs, int nsegs)
     state.edges = segs;
     gts_surface_foreach_edge(s, addEdge, &state);
 
-    gts_surface_foreach_face (s, (GtsFunc) cntFace, &nfaces);
+    gts_surface_foreach_face(s, cntFace, &nfaces);
 
     faces = N_GNEW(3 * nfaces, int);
     neigh = N_GNEW(3 * nfaces, int);
@@ -528,7 +532,7 @@ get_triangles (double *x, int n, int* tris)
     s = tri(x, NULL, n, NULL, 0, 0);
     if (!s) return NULL;
 
-    gts_surface_foreach_face (s, (GtsFunc) cntFace, &nfaces);
+    gts_surface_foreach_face(s, cntFace, &nfaces);
     statf.faces = N_GNEW(3 * nfaces, int);
     gts_surface_foreach_face (s, (GtsFunc) addTri, &statf);