]> granicus.if.org Git - graphviz/commitdiff
mkSurface: fix mismatch of calling convention in 'addFace'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 20:12:53 +0000 (12:12 -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:484:34: warning: cast between incompatible function types from
    ‘void (*)(GFace *, fstate *)’ {aka ‘void (*)(struct <anonymous> *, struct
    <anonymous> *)’} to ‘gint (*)(void *, void *)’ {aka ‘int (*)(void *,
    void *)’} [-Wcast-function-type]
       gts_surface_foreach_face (s, (GtsFunc) addFace, &statf);
                                    ^

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

lib/neatogen/delaunay.c

index 9444d1f12bed5dae081261c0a5de630a0820a4ac..804fde479e5ac621e95ff1d7b9c185dc8ed3f247 100644 (file)
@@ -429,8 +429,10 @@ static gint addNeighbor(void *face, void *ni) {
     return 0;
 }
 
-static void addFace (GFace* f, fstate* es)
-{
+static gint addFace(void *face, void *state) {
+    GFace *f = face;
+    fstate *es = state;
+
     int i, myid = f->idx;
     int* ip = es->faces + 3*myid;
     int* neigh = es->neigh + 3*myid;
@@ -447,6 +449,8 @@ static void addFace (GFace* f, fstate* es)
     gts_face_foreach_neighbor((GtsFace*)f, 0, addNeighbor, &ni);
     for (i = ni.nneigh; i < 3; i++)
        neigh[i] = -1;
+
+    return 0;
 }
 
 static gint addTri(void *face, void *state) {
@@ -504,7 +508,7 @@ mkSurface (double *x, double *y, int n, int* segs, int nsegs)
 
     statf.faces = faces;
     statf.neigh = neigh;
-    gts_surface_foreach_face (s, (GtsFunc) addFace, &statf);
+    gts_surface_foreach_face(s, addFace, &statf);
 
     sf->nedges = nsegs;
     sf->edges = segs;