dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm mode: fix drmIoctl wrapper
@ 2011-06-05 17:28 Marcin Slusarz
  2011-06-19 21:58 ` Marcin Slusarz
  0 siblings, 1 reply; 2+ messages in thread
From: Marcin Slusarz @ 2011-06-05 17:28 UTC (permalink / raw)
  To: dri-devel

Both drmIoctl and ioctl define second argument as unigned long, but
DRM_IOCTL do not.

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 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xf86drmMode.c b/xf86drmMode.c
index 0d268fc..f08e648 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -52,7 +52,7 @@
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
-static inline 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;
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm mode: fix drmIoctl wrapper
  2011-06-05 17:28 [PATCH] drm mode: fix drmIoctl wrapper Marcin Slusarz
@ 2011-06-19 21:58 ` Marcin Slusarz
  0 siblings, 0 replies; 2+ messages in thread
From: Marcin Slusarz @ 2011-06-19 21:58 UTC (permalink / raw)
  To: Chris Wilson; +Cc: dri-devel

On Sun, Jun 05, 2011 at 07:28:20PM +0200, Marcin Slusarz wrote:
> Both drmIoctl and ioctl define second argument as unigned long, but
> DRM_IOCTL do not.
> 
> 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 |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/xf86drmMode.c b/xf86drmMode.c
> index 0d268fc..f08e648 100644
> --- a/xf86drmMode.c
> +++ b/xf86drmMode.c
> @@ -52,7 +52,7 @@
>  #define U642VOID(x) ((void *)(unsigned long)(x))
>  #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
>  
> -static inline 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;
> -- 


Hi Chris,

Can you take a look a this patch?
Commit b803918f3f77c62edf22e78cb2095be399753423 "drm mode: Return -errno
on drmIoctl() failure" reveals you are the author of DRM_IOCTL :).

Thanks,
Marcin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-06-19 21:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-05 17:28 [PATCH] drm mode: fix drmIoctl wrapper Marcin Slusarz
2011-06-19 21:58 ` Marcin Slusarz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox