8000 bpo-28667: Fix a compile warning on FreeBSD when compare with FD_SETS… · python/cpython@cb7fdf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit cb7fdf6

Browse files
authored
bpo-28667: Fix a compile warning on FreeBSD when compare with FD_SETSIZE. (#501) (#3190)
FreeBSD is the only platforms with unsigned FD_SETSIZE. (cherry picked from commit 783d0c1)
1 parent 8e57249 commit cb7fdf6

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Include/fileobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
3939

4040
/* A routine to check if a file descriptor can be select()-ed. */
4141
#ifdef HAVE_SELECT
42-
#define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE))
42+
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
4343
#else
4444
#define _PyIsSelectable_fd(FD) (1)
4545
#endif /* HAVE_SELECT */

Modules/selectmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ typedef struct {
6868
static void
6969
reap_obj(pylist fd2obj[FD_SETSIZE + 1])
7070
{
71-
int i;
72-
for (i = 0; i < FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) {
71+
unsigned int i;
72+
for (i = 0; i < (unsigned int)FD_SETSIZE + 1 && fd2obj[i].sentinel >= 0; i++) {
7373
Py_CLEAR(fd2obj[i].obj);
7474
}
7575
fd2obj[0].sentinel = -1;
@@ -83,7 +83,7 @@ static int
8383
seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
8484
{
8585
int max = -1;
86-
int index = 0;
86+
unsigned int index = 0;
8787
Py_ssize_t i;
8888
PyObject* fast_seq = NULL;
8989
PyObject* o = NULL;
@@ -120,7 +120,7 @@ seq2set(PyObject *seq, fd_set *set, pylist fd2obj[FD_SETSIZE + 1])
120120
FD_SET(v, set);
121121

122122
/* add object and its file descriptor to the list */
123-
if (index >= FD_SETSIZE) {
123+
if (index >= (unsigned int)FD_SETSIZE) {
124124
PyErr_SetString(PyExc_ValueError,
125125
"too many file descriptors in select()");
126126
goto finally;

0 commit comments

Comments
 (0)
0