Explain why we use the unsigned int format for a signed int variable.
authorThomas Wouters <thomas@python.org>
Thu, 2 Mar 2006 17:58:27 +0000 (17:58 +0000)
committerThomas Wouters <thomas@python.org>
Thu, 2 Mar 2006 17:58:27 +0000 (17:58 +0000)
(Should 'code' be cast to the right pointer type?)

Modules/fcntlmodule.c

index d109e29e7c94e626254583990fd09311568ba19a..a368494c969681d53ae068a1062491d1109f25df 100644 (file)
@@ -96,6 +96,10 @@ static PyObject *
 fcntl_ioctl(PyObject *self, PyObject *args)
 {
        int fd;
+       /* In PyArg_ParseTuple below, use the unsigned int 'I' format for
+          the signed int 'code' variable, because Python turns 0x8000000
+          into a large positive number (PyLong, or PyInt on 64-bit
+          platforms,) whereas C expects it to be a negative int */
        int code;
        int arg;
        int ret;