* [PATCH] Fix warning in fs/select.c
@ 2006-04-07 15:37 Russell King
0 siblings, 0 replies; only message in thread
From: Russell King @ 2006-04-07 15:37 UTC (permalink / raw)
To: Linux Kernel List, Andrew Morton
fs/select.c: In function `core_sys_select':
fs/select.c:339: warning: assignment from incompatible pointer type
fs/select.c:376: warning: comparison of distinct pointer types lacks a cast
char *bits;
long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
...
bits = stack_fds;
...
if (bits != stack_fds)
Fix this warning by calculating the number of longs we need for 'n' fds.
This then allows us to do correct pointer arithmetic with the minimum
of fuss.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
diff --git a/fs/select.c b/fs/select.c
--- a/fs/select.c
+++ b/fs/select.c
@@ -310,8 +310,8 @@ static int core_sys_select(int n, fd_set
fd_set __user *exp, s64 *timeout)
{
fd_set_bits fds;
- char *bits;
- int ret, size, max_fdset;
+ long *bits;
+ int ret, size_longs, max_fdset;
struct fdtable *fdt;
/* Allocate small arguments on the stack to save memory and be faster */
long stack_fds[SELECT_STACK_ALLOC/sizeof(long)];
@@ -334,19 +334,19 @@ static int core_sys_select(int n, fd_set
* long-words.
*/
ret = -ENOMEM;
- size = FDS_BYTES(n);
- if (6*size < SELECT_STACK_ALLOC)
+ size_longs = FDS_LONGS(n);
+ if (6 * size_longs * sizeof(long) < SELECT_STACK_ALLOC)
bits = stack_fds;
else
- bits = kmalloc(6 * size, GFP_KERNEL);
+ bits = kmalloc(6 * size_longs * sizeof(long), GFP_KERNEL);
if (!bits)
goto out_nofds;
- fds.in = (unsigned long *) bits;
- fds.out = (unsigned long *) (bits + size);
- fds.ex = (unsigned long *) (bits + 2*size);
- fds.res_in = (unsigned long *) (bits + 3*size);
- fds.res_out = (unsigned long *) (bits + 4*size);
- fds.res_ex = (unsigned long *) (bits + 5*size);
+ fds.in = bits;
+ fds.out = bits + size_longs;
+ fds.ex = bits + 2 * size_longs;
+ fds.res_in = bits + 3 * size_longs;
+ fds.res_out = bits + 4 * size_longs;
+ fds.res_ex = bits + 5 * size_longs;
if ((ret = get_fd_set(n, inp, fds.in)) ||
(ret = get_fd_set(n, outp, fds.out)) ||
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-04-07 15:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-07 15:37 [PATCH] Fix warning in fs/select.c Russell King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox