From: Thomas Wouters Date: Thu, 2 Mar 2006 17:58:27 +0000 (+0000) Subject: Explain why we use the unsigned int format for a signed int variable. X-Git-Tag: v2.5a0~398 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=857b300b2e1c2b27af84d6090ed4810df00f1b16;p=thirdparty%2FPython%2Fcpython.git Explain why we use the unsigned int format for a signed int variable. (Should 'code' be cast to the right pointer type?) --- diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index d109e29e7c94..a368494c9696 100644 --- a/Modules/fcntlmodule.c +++ b/Modules/fcntlmodule.c @@ -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;