From: Russell King <rmk+lkml@arm.linux.org.uk>
To: Linux Kernel List <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>
Subject: [PATCH] Fix warning in fs/select.c
Date: Fri, 7 Apr 2006 16:37:15 +0100 [thread overview]
Message-ID: <20060407153715.GA31458@flint.arm.linux.org.uk> (raw)
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
reply other threads:[~2006-04-07 15:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060407153715.GA31458@flint.arm.linux.org.uk \
--to=rmk+lkml@arm.linux.org.uk \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox