[PATCH libdrm] xf86drm: Fix type-punned pointer build warning

Thierry Reding thierry.reding at gmail.com
Thu Jan 12 21:48:09 UTC 2017


From: Thierry Reding <treding at nvidia.com>

      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]);
                   ^

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
 xf86drmMode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 43cdbbd1ede4..c669774f8fc5 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -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 ||
-- 
2.11.0



More information about the dri-devel mailing list