From c7a4f90197656e7492fda8e2e0016925feb562aa Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 7 Nov 2021 12:07:00 -0800 Subject: [PATCH] get_triangles: fix mismatch of calling convention in 'addTri' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The compiler said about this code: delaunay.c:518:34: warning: cast between incompatible function types from ‘void (*)(GFace *, fstate *)’ {aka ‘void (*)(struct *, struct *)’} 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/neatogen/delaunay.c b/lib/neatogen/delaunay.c index 08805abdc..9444d1f12 100644 --- a/lib/neatogen/delaunay.c +++ b/lib/neatogen/delaunay.c @@ -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)); -- 2.40.0