SHA256
1
0
forked from pool/graphviz
graphviz/graphviz-aliasing-fixes.patch

109 lines
3.0 KiB
Diff

--- lib/agraph/edge.c
+++ lib/agraph/edge.c
@@ -149,28 +149,29 @@
void agedgesetop(Agraph_t * g, Agedge_t * e, int ins)
{
- Dtlink_t **seq_set, **id_set;
+ union {
+ Dtlink_t **dtlink;
+ Agedge_t **agedge;
+ } seq_set;
+ Dtlink_t **id_set;
Agnode_t *n; /* node where <e> is referenced */
- Agedge_t **tmp;
if (AGTYPE(e) == AGOUTEDGE) {
n = AGOUT2IN(e)->node;
- tmp = &(n->out); /* avoiding - "dereferencing type-punned pointer will break strict-aliasing rules" */
- seq_set = (Dtlink_t **)tmp;
+ seq_set.agedge = &(n->out);
id_set = &(n->outid);
} else {
n = AGIN2OUT(e)->node;
- tmp = &(n->in);
- seq_set = (Dtlink_t **)tmp;
+ seq_set.agedge = &(n->in);
id_set = &(n->inid);
}
- dtrestore(g->e_seq, *seq_set);
+ dtrestore(g->e_seq, *seq_set.dtlink);
if (ins)
dtinsert(g->e_seq, e);
else
dtdelete(g->e_seq, e);
- *seq_set = dtextract(g->e_seq);
+ *seq_set.dtlink = dtextract(g->e_seq);
dtrestore(g->e_id, *id_set);
if (ins)
--- lib/agraph/flatten.c
+++ lib/agraph/flatten.c
@@ -26,13 +26,17 @@
void agflatten_edges(Agraph_t * g, Agnode_t * n)
{
- Agedge_t **tmp;
- tmp = &(n->out); /* avoiding - "dereferencing type-punned pointer will break strict-aliasing rules" */
+ union {
+ Dtlink_t **dtlink;
+ Agedge_t **agedge;
+ } out, in;
+
+ out.agedge = & (n->out);
+ in.agedge = & (n->in);
+ agflatten_elist(g->e_seq, out.dtlink);
+ agflatten_elist(g->e_seq, in.dtlink);
- agflatten_elist(g->e_seq, (Dtlink_t **) tmp);
- tmp = &(n->in);
- agflatten_elist(g->e_seq, (Dtlink_t **) tmp);
}
void agflatten(Agraph_t * g, int flag)
--- lib/gd/fontwheeltest.c
+++ lib/gd/fontwheeltest.c
@@ -21,8 +21,10 @@
dowheel (gdImagePtr im, int color, char *fontfile, int fontsize,
double angle, int x, int y, int offset, char *string)
{
- int brect[8];
- gdPoint points[4];
+ union {
+ int coords[8];
+ gdPoint points[4];
+ } brect;
int i;
FILE *err;
double curangrads, curang, x0, y0;
@@ -42,24 +44,16 @@
/* The case of newlines is taken care of in the gdImageStringTTF call */
#if defined(OLDER_GD)
- cp = gdImageStringTTF (im, brect, color, fontfile, fontsize,
+ cp = gdImageStringTTF (im, brect.coords, color, fontfile, fontsize,
curangrads, x0, y0, string);
#else
- cp = gdImageStringFT (im, brect, color, fontfile, fontsize,
+ cp = gdImageStringFT (im, brect.coords, color, fontfile, fontsize,
curangrads, x0, y0, string);
#endif
if (cp)
doerr (err, cp);
- /* FIXME - this is silly, but if we try to cast int[] to gdPointPtr
- * we get a "warning: dereferencing type-punned pointer will break strict -aliasing rules" from gcc
- * The proper fix probably requires an API change to use gdPoint[] in gdImageString*
- */
- for (i = 0; i < 4; i++) {
- points[i].x = brect[2*i];
- points[i].y = brect[2*i + 1];
- }
- gdImagePolygon (im, points, 4, color);
+ gdImagePolygon (im, brect.points, 4, color);
}
fclose (err);