public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bitmap: remove explicit newline handling using scnprintf format string
@ 2015-04-27  9:46 Sudeep Holla
  2015-04-27 16:14 ` Tejun Heo
  2015-04-28 15:36 ` [PATCH v2] " Sudeep Holla
  0 siblings, 2 replies; 9+ messages in thread
From: Sudeep Holla @ 2015-04-27  9:46 UTC (permalink / raw)
  To: linux-kernel
  Cc: Sudeep Holla, Pawel Moll, Andrew Morton, Tejun Heo,
	Peter Zijlstra (Intel)

bitmap_print_to_pagebuf uses scnprintf to copy the cpumask/list to page
buffer. It handles the newline and trailing null character explicitly.

It's unnecessary and also partially duplicated as scnprintf already adds
trailing null character. The newline can be passed through format string
to scnprintf. This patch does that simplification.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Suggested-by: Pawel Moll <Pawel.Moll@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 lib/bitmap.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/lib/bitmap.c b/lib/bitmap.c
index 64c0926f5dd8..9b24b57b4b01 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -466,15 +466,12 @@ EXPORT_SYMBOL(bitmap_parse_user);
 int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp,
 			    int nmaskbits)
 {
-	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2;
+	ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
 	int n = 0;

-	if (len > 1) {
-		n = list ? scnprintf(buf, len, "%*pbl", nmaskbits, maskp) :
-			   scnprintf(buf, len, "%*pb", nmaskbits, maskp);
-		buf[n++] = '\n';
-		buf[n] = '\0';
-	}
+	if (len > 1)
+		n = list ? scnprintf(buf, len, "%*pbl\n", nmaskbits, maskp) :
+			   scnprintf(buf, len, "%*pb\n", nmaskbits, maskp);
 	return n;
 }
 EXPORT_SYMBOL(bitmap_print_to_pagebuf);
--
1.9.1


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-04-30  8:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-27  9:46 [PATCH] bitmap: remove explicit newline handling using scnprintf format string Sudeep Holla
2015-04-27 16:14 ` Tejun Heo
2015-04-27 16:26   ` Sudeep Holla
2015-04-27 16:30     ` Tejun Heo
2015-04-27 16:39       ` Sudeep Holla
2015-04-27 16:40         ` Tejun Heo
2015-04-28 15:36 ` [PATCH v2] " Sudeep Holla
2015-04-29 22:48   ` Andrew Morton
2015-04-30  8:23     ` Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox