posix_types.h: Cleanup stale __NFDBITS and related definitions
Recently, glibc made a change to suppress sign-conversion warnings in
FD_SET (glibc commit ceb9e56b3d1). This uncovered an issue with the
kernel's definition of __NFDBITS if applications #include
<linux/types.h> after including <sys/select.h>. A build failure would
be seen when passing the -Werror=sign-compare and -D_FORTIFY_SOURCE=2
flags to gcc.
It was suggested that the kernel should either match the glibc
definition of __NFDBITS or remove that entirely. The current in-kernel
uses of __NFDBITS can be replaced with BITS_PER_LONG, and there are no
uses of the related __FDELT and __FDMASK defines. Given that, we'll
continue the cleanup that was started with commit 8b3d1cda4f
("posix_types: Remove fd_set macros") and drop the remaining unused
macros.
Additionally, linux/time.h has similar macros defined that expand to
nothing so we'll remove those at the same time.
Reported-by: Jeff Law <law@redhat.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
CC: <stable@vger.kernel.org>
Signed-off-by: Josh Boyer <jwboyer@redhat.com>
[ .. and fix up whitespace as per akpm ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Este cometimento está contido em:

cometido por
Linus Torvalds

ascendente
4cb38750d4
cometimento
8ded2bbc18
10
fs/select.c
10
fs/select.c
@@ -345,8 +345,8 @@ static int max_select_fd(unsigned long n, fd_set_bits *fds)
|
||||
struct fdtable *fdt;
|
||||
|
||||
/* handle last in-complete long-word first */
|
||||
set = ~(~0UL << (n & (__NFDBITS-1)));
|
||||
n /= __NFDBITS;
|
||||
set = ~(~0UL << (n & (BITS_PER_LONG-1)));
|
||||
n /= BITS_PER_LONG;
|
||||
fdt = files_fdtable(current->files);
|
||||
open_fds = fdt->open_fds + n;
|
||||
max = 0;
|
||||
@@ -373,7 +373,7 @@ get_max:
|
||||
max++;
|
||||
set >>= 1;
|
||||
} while (set);
|
||||
max += n * __NFDBITS;
|
||||
max += n * BITS_PER_LONG;
|
||||
}
|
||||
|
||||
return max;
|
||||
@@ -435,11 +435,11 @@ int do_select(int n, fd_set_bits *fds, struct timespec *end_time)
|
||||
in = *inp++; out = *outp++; ex = *exp++;
|
||||
all_bits = in | out | ex;
|
||||
if (all_bits == 0) {
|
||||
i += __NFDBITS;
|
||||
i += BITS_PER_LONG;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = 0; j < __NFDBITS; ++j, ++i, bit <<= 1) {
|
||||
for (j = 0; j < BITS_PER_LONG; ++j, ++i, bit <<= 1) {
|
||||
int fput_needed;
|
||||
if (i >= n)
|
||||
break;
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador