Skip to contentSkip to conversation

Fold select_bits_alloc/free into caller code.

PATCH New Vadim Lobanov 1 participant 1 message Mar 7, 2006 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fold select_bits_alloc/free into caller code.

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.

fs/compat.c +2 -11
diff -Npru linux-2.6.16-rc5/fs/compat.c linux-new/fs/compat.c
@@ -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;
 }
fs/select.c +2 -12
diff -Npru linux-2.6.16-rc5/fs/select.c linux-new/fs/select.c
@@ -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;
 }