From f0d28f7609cb4fea6a7ee5393958642aa65b545d Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 6 Nov 2022 10:19:29 -0800 Subject: [PATCH] cgraph: fix mismatched type signatures between 'agobjfn_t' and 'agraphattr_init' MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Squashes a compiler warning: attr.c: In function ‘init_all_attrs’: attr.c:534:37: warning: cast between incompatible function types from ‘void (*)(Agraph_t *)’ {aka ‘void (*)(struct Agraph_s *)’} to ‘void (*)(Agraph_t *, Agobj_t *, void *)’ {aka ‘void (*)(struct Agraph_s *, struct Agobj_s *, void *)’} [-Wcast-function-type] 534 | agapply(root, (Agobj_t *) root, (agobjfn_t) agraphattr_init, | ^ This code was incorrect. But on the most common architecture in contemporary use, x86-64, the calling convention for both is fully in registers, so no user visible misbehavior would have been seen. Gitlab: #2300 --- lib/cgraph/attr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cgraph/attr.c b/lib/cgraph/attr.c index dea9dfe7c..4c5c23fb5 100644 --- a/lib/cgraph/attr.c +++ b/lib/cgraph/attr.c @@ -518,6 +518,13 @@ int agsafeset(void *obj, char *name, const char *value, const char *def) { return agxset(obj, a, value); } +static void agraphattr_init_wrapper(Agraph_t *g, Agobj_t *ignored1, + void *ignored2) { + (void)ignored1; + (void)ignored2; + + agraphattr_init(g); +} /* * attach attributes to the already created graph objs. @@ -531,8 +538,7 @@ static void init_all_attrs(Agraph_t * g) Agedge_t *e; root = agroot(g); - agapply(root, (Agobj_t *) root, (agobjfn_t) agraphattr_init, - NULL, TRUE); + agapply(root, (Agobj_t*)root, agraphattr_init_wrapper, NULL, TRUE); for (n = agfstnode(root); n; n = agnxtnode(root, n)) { agnodeattr_init(g, n); for (e = agfstout(root, n); e; e = agnxtout(root, e)) { -- 2.40.0