[PATCH] Fold select_bits_alloc/free into caller code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

This patch removes what currently seems to be an unnecessary level of
indirection in allocating and freeing select bits, as per the
select_bits_alloc() and select_bits_free() functions. Both select.c and
compat.c are updated.

Signed-off-by: Vadim Lobanov <[email protected]>

diff -Npru linux-2.6.16-rc5/fs/compat.c linux-new/fs/compat.c
--- linux-2.6.16-rc5/fs/compat.c	2006-03-06 20:07:34.000000000 -0800
+++ linux-new/fs/compat.c	2006-03-06 20:12:13.000000000 -0800
@@ -1638,15 +1638,6 @@ void compat_set_fd_set(unsigned long nr,
  * This is a virtual copy of sys_select from fs/select.c and probably
  * should be compared to it from time to time
  */
-static void *select_bits_alloc(int size)
-{
-	return kmalloc(6 * size, GFP_KERNEL);
-}
-
-static void select_bits_free(void *bits, int size)
-{
-	kfree(bits);
-}

 /*
  * We can actually return ERESTARTSYS instead of EINTR, but I'd
@@ -1685,7 +1676,7 @@ int compat_core_sys_select(int n, compat
 	 */
 	ret = -ENOMEM;
 	size = FDS_BYTES(n);
-	bits = select_bits_alloc(size);
+	bits = kmalloc(6 * size, GFP_KERNEL);
 	if (!bits)
 		goto out_nofds;
 	fds.in      = (unsigned long *)  bits;
@@ -1719,7 +1710,7 @@ int compat_core_sys_select(int n, compat
 	compat_set_fd_set(n, exp, fds.res_ex);

 out:
-	select_bits_free(bits, size);
+	kfree(bits);
 out_nofds:
 	return ret;
 }
diff -Npru linux-2.6.16-rc5/fs/select.c linux-new/fs/select.c
--- linux-2.6.16-rc5/fs/select.c	2006-03-06 20:07:35.000000000 -0800
+++ linux-new/fs/select.c	2006-03-06 20:13:11.000000000 -0800
@@ -284,16 +284,6 @@ int do_select(int n, fd_set_bits *fds, s
 	return retval;
 }

-static void *select_bits_alloc(int size)
-{
-	return kmalloc(6 * size, GFP_KERNEL);
-}
-
-static void select_bits_free(void *bits, int size)
-{
-	kfree(bits);
-}
-
 /*
  * We can actually return ERESTARTSYS instead of EINTR, but I'd
  * like to be certain this leads to no problems. So I return
@@ -332,7 +322,7 @@ static int core_sys_select(int n, fd_set
 	 */
 	ret = -ENOMEM;
 	size = FDS_BYTES(n);
-	bits = select_bits_alloc(size);
+	bits = kmalloc(6 * size, GFP_KERNEL);
 	if (!bits)
 		goto out_nofds;
 	fds.in      = (unsigned long *)  bits;
@@ -367,7 +357,7 @@ static int core_sys_select(int n, fd_set
 		ret = -EFAULT;

 out:
-	select_bits_free(bits, size);
+	kfree(bits);
 out_nofds:
 	return ret;
 }
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux