Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 857b300

Browse files
committed
Explain why we use the unsigned int format for a signed int variable.
(Should 'code' be cast to the right pointer type?)
1 parent 4954b38 commit 857b300

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Modules/fcntlmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ static PyObject *
9696
fcntl_ioctl(PyObject *self, PyObject *args)
9797
{
9898
int fd;
99+
/* In PyArg_ParseTuple below, use the unsigned int 'I' format for
100+
the signed int 'code' variable, because Python turns 0x8000000
101+
into a large positive number (PyLong, or PyInt on 64-bit
102+
platforms,) whereas C expects it to be a negative int */
99103
int code;
100104
int arg;
101105
int ret;

0 commit comments

Comments
 (0)