mirror of
https://github.com/python/cpython.git
synced 2025-09-29 03:35:31 +00:00
FreeBSD is the only platforms with unsigned FD_SETSIZE.
(cherry picked from commit 783d0c1a1c
)
This commit is contained in:
parent
8e572491b5
commit
cb7fdf69ec
2 changed files with 5 additions and 5 deletions
|
@ -39,7 +39,7 @@ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
|
||||||
|
|
||||||
/* A routine to check if a file descriptor can be select()-ed. */
|
/* A routine to check if a file descriptor can be select()-ed. */
|
||||||
#ifdef HAVE_SELECT
|
#ifdef HAVE_SELECT
|
||||||
#define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
|
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
|
||||||
#else
|
#else
|
||||||
#define _PyIsSelectable_fd(FD) (1)
|
#define _PyIsSelectable_fd(FD) (1)
|
||||||
#endif /* HAVE_SELECT */
|
#endif /* HAVE_SELECT */
|
||||||
|
|
|
@ -68,8 +68,8 @@ typedef struct {
|
||||||
static void
|
static void
|
||||||
reap_obj(pylist fd2obj[FD_SETSIZE + 1])
|
reap_obj(pylist fd2obj[FD_SETSIZE + 1])
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) {
|
for (i = 0; i < (unsigned int)FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) {
|
||||||
Py_CLEAR(fd2obj[i].obj);
|
Py_CLEAR(fd2obj[i].obj);
|
||||||
}
|
}
|
||||||
fd2obj[0].sentinel = -1;
|
fd2obj[0].sentinel = -1;
|
||||||
|
@ -83,7 +83,7 @@ static int
|
||||||
seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
|
seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
|
||||||
{
|
{
|
||||||
int max = -1;
|
int max = -1;
|
||||||
int index = 0;
|
unsigned int index = 0;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
PyObject* fast_seq = NULL;
|
PyObject* fast_seq = NULL;
|
||||||
PyObject* o = NULL;
|
PyObject* o = NULL;
|
||||||
|
@ -120,7 +120,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
|
||||||
FD_SET(v, set);
|
FD_SET(v, set);
|
||||||
|
|
||||||
/* add object and its file descriptor to the list */
|
/* add object and its file descriptor to the list */
|
||||||
if (index >= FD_SETSIZE) {
|
if (index >= (unsigned int)FD_SETSIZE) {
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"too many file descriptors in select()");
|
"too many file descriptors in select()");
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue