]> granicus.if.org Git - graphviz/commitdiff
addFace: fix mismatch of calling convention in callback
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 19:40:52 +0000 (11:40 -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: In function ‘addFace’:
  delaunay.c:428:48: warning: cast between incompatible function types from
    ‘void (*)(GFace *, ninfo *)’ {aka ‘void (*)(struct <anonymous> *, struct
    <anonymous> *)’} to ‘gint (*)(void *, void *)’ {aka ‘int (*)(void *,
    void *)’} [-Wcast-function-type]
       gts_face_foreach_neighbor ((GtsFace*)f, 0, (GtsFunc) addNeighbor, &ni);
                                                  ^

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

lib/neatogen/delaunay.c

index 0ff436645bc2c595644a8859a06e29de9e6b9f3a..ac578ab6da9f0d776d37f7980a9b8f3d4b1f0487 100644 (file)
@@ -411,10 +411,14 @@ typedef struct {
     int* neigh;
 } ninfo;
 
-static void addNeighbor (GFace* f, ninfo* es)
-{
+static gint addNeighbor(void *face, void *ni) {
+    GFace *f = face;
+    ninfo *es = ni;
+
     es->neigh[es->nneigh] = f->idx;
     es->nneigh++;
+
+    return 0;
 }
 
 static void addFace (GFace* f, fstate* es)
@@ -432,7 +436,7 @@ static void addFace (GFace* f, fstate* es)
 
     ni.nneigh = 0;
     ni.neigh = neigh;
-    gts_face_foreach_neighbor ((GtsFace*)f, 0, (GtsFunc) addNeighbor, &ni);
+    gts_face_foreach_neighbor((GtsFace*)f, 0, addNeighbor, &ni);
     for (i = ni.nneigh; i < 3; i++)
        neigh[i] = -1;
 }