Skip to contentSkip to conversation

xf86drm: Fix type-punned pointer build warning

PATCH In review Thierry Reding 2 participants 2 messages Jan 12, 2017 – Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xf86drm: Fix type-punned pointer build warning

From: Thierry Reding <[email protected]>

CC libdrm_la-xf86drmMode.lo
../xf86drmMode.c: In function 'drmHandleEvent':
../xf86drmMode.c:854:15: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
e = (struct drm_event *)(&buffer[i]);
^

---
 xf86drmMode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xf86drmMode.c +1 -1
index 43cdbbd1ede4..c669774f8fc5 100644
@@ -901,7 +901,7 @@ int drmHandleEvent(int fd, drmEventContextPtr evctx)
 
 	i = 0;
 	while (i < len) {
-		e = (struct drm_event *) &buffer[i];
+		e = (struct drm_event *)(buffer + i);
 		switch (e->type) {
 		case DRM_EVENT_VBLANK:
 			if (evctx->version < 1 ||
Signature · 6 lines
2.11.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Thierry Reding

From: Thierry Reding <[email protected]>

CC libdrm_la-xf86drmMode.lo
../xf86drmMode.c: In function 'drmHandleEvent':
../xf86drmMode.c:854:15: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
e = (struct drm_event *)(&buffer[i]);
^

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99350

-Emil
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel