From 857b300b2e1c2b27af84d6090ed4810df00f1b16 Mon Sep 17 00:00:00 2001 From: Thomas Wouters Date: Thu, 2 Mar 2006 17:58:27 +0000 Subject: Explain why we use the unsigned int format for a signed int variable. (Should 'code' be cast to the right pointer type?) --- Modules/fcntlmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Modules/fcntlmodule.c b/Modules/fcntlmodule.c index d109e29..a368494 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; -- cgit v0.12