XShapeEvent strict aliasing violation

C99 defines new strict aliasing rules to allow compilers to make certain
optimizations. These rules prohibit converting an XEvent to an event
struct (e.g. XShapeEvent) that is not already in the XEvent union using
pointer type punning (e.g. "(XShapeEvent *)&ev"), and vice versa. The
canonical fix seems to be to create a union between XEvent and the
extension event struct to make the aliasing explicit, so do that.
This commit is contained in:
Brad Jorsch authored and Carlos R. Mafra committed 2010-04-12 09:58:36 +02:00
1 parent 3be81b0243
commit bbf3635590
1 file changed
+9 -8
+9 -8
View File
@@ -1159,16 +1159,17 @@ static void handleShapeNotify(XEvent * event)
{
XShapeEvent *shev = (XShapeEvent *) event;
WWindow *wwin;
XEvent ev;
union {
XEvent xevent;
XShapeEvent xshape;
} ev;
while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev)) {
XShapeEvent *sev = (XShapeEvent *) & ev;
if (sev->kind == ShapeBounding) {
if (sev->shaped == shev->shaped) {
*shev = *sev;
while (XCheckTypedWindowEvent(dpy, shev->window, event->type, &ev.xevent)) {
if (ev.xshape.kind == ShapeBounding) {
if (ev.xshape.shaped == shev->shaped) {
*shev = ev.xshape;
} else {
XPutBackEvent(dpy, &ev);
XPutBackEvent(dpy, &ev.xevent);
break;
}
}