]> granicus.if.org Git - graphviz/commitdiff
get_triangles: fix mismatch of calling convention in 'addTri'
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 20:07:00 +0000 (12:07 -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:518: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) addTri, &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 08805abdc9cfcbf693a709327a629699af91fd24..9444d1f12bed5dae081261c0a5de630a0820a4ac 100644 (file)
@@ -449,8 +449,10 @@ static void addFace (GFace* f, fstate* es)
        neigh[i] = -1;
 }
 
-static void addTri (GFace* f, fstate* es)
-{
+static gint addTri(void *face, void *state) {
+    GFace *f = face;
+    fstate *es = state;
+
     int myid = f->idx;
     int* ip = es->faces + 3*myid;
     GtsVertex *v1, *v2, *v3;
@@ -459,6 +461,8 @@ static void addTri (GFace* f, fstate* es)
     *ip++ = ((GVertex*)(v1))->idx;
     *ip++ = ((GVertex*)(v2))->idx;
     *ip++ = ((GVertex*)(v3))->idx;
+
+    return 0;
 }
 
 /* mkSurface:
@@ -534,7 +538,7 @@ get_triangles (double *x, int n, int* tris)
 
     gts_surface_foreach_face(s, cntFace, &nfaces);
     statf.faces = N_GNEW(3 * nfaces, int);
-    gts_surface_foreach_face (s, (GtsFunc) addTri, &statf);
+    gts_surface_foreach_face(s, addTri, &statf);
 
     gts_object_destroy (GTS_OBJECT (s));