]> granicus.if.org Git - graphviz/commitdiff
delaunay_triangulation: fix mismatch of calling convention in callback
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 19:25:21 +0000 (11:25 -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:286:34: warning: cast between incompatible function types from
    ‘void (*)(GtsSegment *, v_data *)’ {aka ‘void (*)(struct _GtsSegment *,
    struct <anonymous> *)’} to ‘gint (*)(void *, void *)’ {aka
    ‘int (*)(void *, void *)’} [-Wcast-function-type]
       gts_surface_foreach_edge (s, (GtsFunc) add_edge, delaunay);
                                    ^

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

lib/neatogen/delaunay.c

index 8eda791949d208bb8a07a0a7994f072be121341e..0ff436645bc2c595644a8859a06e29de9e6b9f3a 100644 (file)
@@ -249,13 +249,17 @@ edgeStats (GtsSurface* s, estats* sp)
     gts_surface_foreach_edge(s, cnt_edge, sp);
 }
 
-static void add_edge (GtsSegment * e, v_data* delaunay)
-{
+static gint add_edge(void *edge, void *data) {
+    GtsSegment *e = edge;
+    v_data *delaunay = data;
+
     int source = ((GVertex*)(e->v1))->idx;
     int dest = ((GVertex*)(e->v2))->idx;
 
     delaunay[source].edges[delaunay[source].nedges++] = dest;
     delaunay[dest].edges[delaunay[dest].nedges++] = source;
+
+    return 0;
 }
 
 static v_data *delaunay_triangulation(double *x, double *y, int n) {
@@ -286,7 +290,7 @@ static v_data *delaunay_triangulation(double *x, double *y, int n) {
        delaunay[i].edges[0] = i;
        delaunay[i].nedges = 1;
     }
-    gts_surface_foreach_edge (s, (GtsFunc) add_edge, delaunay);
+    gts_surface_foreach_edge(s, add_edge, delaunay);
 
     gts_object_destroy (GTS_OBJECT (s));