drm mode: fix drmIoctl wrapper
authorMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 5 Jun 2011 16:53:16 +0000 (18:53 +0200)
committerMarcin Slusarz <marcin.slusarz@gmail.com>
Sun, 18 Sep 2011 13:25:18 +0000 (15:25 +0200)
Both drmIoctl and ioctl define second argument as unigned long.

Debugging/tracing tools (like strace or valgrind) on 64-bit machines see
different request value for ioctls with 32nd bit set, because casting
signed int to unsigned long extends 32nd bit to upper word, so 0x80000000
becomes 0xFFFFFFFF80000000)

Nobody noticed because higher 32 bits are chopped off on their way to kernel.

xf86drmMode.c

index c94e40c..f08e648 100644 (file)
@@ -52,7 +52,7 @@
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
-static inline int DRM_IOCTL(int fd, int cmd, void *arg)
+static inline int DRM_IOCTL(int fd, unsigned long cmd, void *arg)
 {
        int ret = drmIoctl(fd, cmd, arg);
        return ret < 0 ? -errno : ret;