]> granicus.if.org Git - graphviz/commitdiff
gts_surface_foreach_edge: fix mismatch of calling convention in callback
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 7 Nov 2021 19:20:08 +0000 (11:20 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Wed, 10 Nov 2021 02:34:07 +0000 (18:34 -0800)
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 <anonymous> *)’} 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
lib/neatogen/delaunay.c

index 5a56cd8e2549b85c8e9d1ea70c205b743ad95ae8..258f517e3922e6b61049353b0168150de9811cf4 100644 (file)
@@ -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
 
index 6e12dd3abc36136dd7011e2612ff038680c409a2..8eda791949d208bb8a07a0a7994f072be121341e 100644 (file)
@@ -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)