Although POSIX says the type is 'int', all BSD variants (including Mac OS X) have been using 'unsigned long' type for very long time and its use predates the standard long enough. For certain commands (e.g., TIOCSWINSZ, FIONBIO), the Python value may get sign-extended on 64-bit platforms (by implicit type promotion) and it causes annoying warnings from kernel such as this: WARNING pid 24509 (python2.6): ioctl sign-extension ioctl ffffffff8004667e Approved by: python (maintainer timeout)
39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
--- Modules/fcntlmodule.c.orig 2006-09-27 15:17:32.000000000 -0400
|
|
+++ Modules/fcntlmodule.c 2010-06-24 21:15:48.000000000 -0400
|
|
@@ -95,7 +95,7 @@
|
|
{
|
|
#define IOCTL_BUFSZ 1024
|
|
int fd;
|
|
- int code;
|
|
+ unsigned long code;
|
|
int arg;
|
|
int ret;
|
|
char *str;
|
|
@@ -103,7 +103,7 @@
|
|
int mutate_arg = 0;
|
|
char buf[IOCTL_BUFSZ+1]; /* argument plus NUL byte */
|
|
|
|
- if (PyArg_ParseTuple(args, "O&iw#|i:ioctl",
|
|
+ if (PyArg_ParseTuple(args, "O&kw#|i:ioctl",
|
|
conv_descriptor, &fd, &code,
|
|
&str, &len, &mutate_arg)) {
|
|
char *arg;
|
|
@@ -164,7 +164,7 @@
|
|
}
|
|
|
|
PyErr_Clear();
|
|
- if (PyArg_ParseTuple(args, "O&is#:ioctl",
|
|
+ if (PyArg_ParseTuple(args, "O&ks#:ioctl",
|
|
conv_descriptor, &fd, &code, &str, &len)) {
|
|
if (len > IOCTL_BUFSZ) {
|
|
PyErr_SetString(PyExc_ValueError,
|
|
@@ -186,7 +186,7 @@
|
|
PyErr_Clear();
|
|
arg = 0;
|
|
if (!PyArg_ParseTuple(args,
|
|
- "O&i|i;ioctl requires a file or file descriptor,"
|
|
+ "O&k|i;ioctl requires a file or file descriptor,"
|
|
" an integer and optionally a integer or buffer argument",
|
|
conv_descriptor, &fd, &code, &arg)) {
|
|
return NULL;
|