From 13a514216ad6408f185a17c3c568f967d27d7daa Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 7 Nov 2021 11:20:08 -0800 Subject: [PATCH] gts_surface_foreach_edge: fix mismatch of calling convention in callback MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The compiler said about this code: delaunay.c: In function ‘edgeStats’: delaunay.c:245:34: warning: cast between incompatible function types from ‘void (*)(GtsSegment *, estats *)’ {aka ‘void (*)(struct _GtsSegment *, struct *)’} to ‘gint (*)(void *, void *)’ {aka ‘int (*)(void *, void *)’} [-Wcast-function-type] gts_surface_foreach_edge (s, (GtsFunc) cnt_edge, sp); ^ This is not quite as bad as the previous instance of this fixed. However, it seems to have been relying on a coincident return value. E.g. on x86-64 this code relies on 0 ending up in `RAX` at the end of the callback to indicate iteration should continue, despite `cnt_edge` having no declared return value. --- CHANGELOG.md | 2 +- lib/neatogen/delaunay.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a56cd8e2..258f517e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - remove Bashism from `gvmap.sh` #2151 - Lefty artifacts are no longer installed when Lefty is disabled #2153 - Smyrna artifacts are no longer installed when Smyrna is disabled -- calling convention mismatch in delaunay.c’s GTS code +- calling convention mismatches in delaunay.c’s GTS code ## [2.49.3] – 2021-10-22 diff --git a/lib/neatogen/delaunay.c b/lib/neatogen/delaunay.c index 6e12dd3ab..8eda79194 100644 --- a/lib/neatogen/delaunay.c +++ b/lib/neatogen/delaunay.c @@ -230,19 +230,23 @@ typedef struct { v_data *delaunay; } estats; -static void cnt_edge (GtsSegment * e, estats* sp) -{ +static gint cnt_edge(void *edge, void *stats) { + GtsSegment *e = edge; + estats *sp = stats; + sp->n++; if (sp->delaunay) { sp->delaunay[((GVertex*)(e->v1))->idx].nedges++; sp->delaunay[((GVertex*)(e->v2))->idx].nedges++; } + + return 0; } static void edgeStats (GtsSurface* s, estats* sp) { - gts_surface_foreach_edge (s, (GtsFunc) cnt_edge, sp); + gts_surface_foreach_edge(s, cnt_edge, sp); } static void add_edge (GtsSegment * e, v_data* delaunay) -- 2.40.0