Skip to contentSkip to conversation

cpuset crapectomy

PATCH In review Al Viro 2 participants 2 messages Sep 30, 2005

lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 cpuset crapectomy

Switched cpuset_common_file_read() to simple_read_from_buffer(),
killed a bunch of useless (and not quite correct - e.g. min(size_t,ssize_t)) code.

----

kernel/cpuset.c +1 -11
diff -urN RC14-rc2-git6-base/kernel/cpuset.c current/kernel/cpuset.c
@@ -968,8 +968,6 @@
 	char *page;
 	ssize_t retval = 0;
 	char *s;
-	char *start;
-	ssize_t n;
 
 	if (!(page = (char *)__get_free_page(GFP_KERNEL)))
 		return -ENOMEM;
@@ -999,15 +997,7 @@
 	*s++ = '\n';
 	*s = '\0';
 
-	start = page + *ppos;
-	n = s - start;
-
-	/* Do nothing if *ppos is at the eof or beyond the eof. */
-	if (n <= 0)
-		goto out;
-
-	retval = n - copy_to_user(buf, start, min(n, nbytes));
-	*ppos += retval;
+	retval = simple_read_from_buffer(buf, nbytes, ppos, page, s - page);
 out:
 	free_page((unsigned long)page);
 	return retval;
#1 lore raw

Thanks, Al, for picking up after us.

Actually, we can remove one more line of code. The line right above the code you ripped out is:

	*s = '\0';

I think this line is utterly useless.

Perhaps I can find time to prepare a trivial "cpuset crapectomy stage two" patch to remove this line too.

Signature · 3 lines
                  I won't rest till it's the best ...
                  Programmer, Linux Scalability
                  Paul Jackson <[email protected]> 1.925.600.0401