changeset 14383:e514f670d508

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>.
author Bruno Haible <bruno@clisp.org>
date Wed, 23 Feb 2011 00:01:03 +0100
parents c19d2aef45e7
children 588ed4cdea87
files ChangeLog lib/ioctl.c
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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
--- a/lib/ioctl.c
+++ b/lib/ioctl.c
@@ -37,7 +37,9 @@
   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 */