From: Matthew Fernandez Date: Sun, 7 Nov 2021 19:40:52 +0000 (-0800) Subject: addFace: fix mismatch of calling convention in callback X-Git-Tag: 2.50.0~41^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fce4aede14c7163c080940ab9d47c7e1b551a45e;p=graphviz addFace: fix mismatch of calling convention in callback 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 *, struct *)’} 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. --- diff --git a/lib/neatogen/delaunay.c b/lib/neatogen/delaunay.c index 0ff436645..ac578ab6d 100644 --- a/lib/neatogen/delaunay.c +++ b/lib/neatogen/delaunay.c @@ -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; }