ioctl: Fix for MacOS X in 64-bit mode.
authorBruno Haible <bruno@clisp.org>
Tue, 22 Feb 2011 23:01:03 +0000 (00:01 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 22 Feb 2011 23:01:03 +0000 (00:01 +0100)
* lib/ioctl.c (rpl_ioctl): Zero-extend, not sign-extend, the request
value.
Suggested by Eric Blake.
Reported by Markus Gothe <nietzsche@lysator.liu.se>.

ChangeLog
lib/ioctl.c

index ee86ca9..f2e9ee0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-22  Bruno Haible  <bruno@clisp.org>
+
+       ioctl: Fix for MacOS X in 64-bit mode.
+       * lib/ioctl.c (rpl_ioctl): Zero-extend, not sign-extend, the request
+       value.
+       Suggested by Eric Blake.
+       Reported by Markus Gothe <nietzsche@lysator.liu.se>.
+
 2011-02-22  Jim Meyering  <meyering@redhat.com>
 
        maint: sc_cpp_indent_check: remove the "only in lib/" restriction
index 72f9f37..7c09d95 100644 (file)
@@ -37,7 +37,9 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */)
   buf = va_arg (args, void *);
   va_end (args);
 
-  return ioctl (fd, request, buf);
+  /* Cast 'request' so that when the system's ioctl function takes a 64-bit
+     request argument, the value gets zero-extended, not sign-extended.  */
+  return ioctl (fd, (unsigned int) request, buf);
 }
 
 #else /* mingw */