From: Matthew Wilcox <willy@infradead.org>
Date: Wed, 19 Dec 2018 15:44:30 +0000 (-0500)
Subject: printf: Convert bitmap_list_string to printf_state
X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=0c6af1f80b2319d81f27df0164b42b8ac2ccc993;p=users%2Fwilly%2Flinux.git

printf: Convert bitmap_list_string to printf_state

Signed-off-by: Matthew Wilcox <willy@infradead.org>
---

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index a1e410f9be48..4468bbcdc142 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1020,14 +1020,14 @@ char *bitmap_string(char *buf, char *end, unsigned long *bitmap,
 }
 
 static noinline_for_stack
-char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,
-			 struct printf_spec spec, const char *fmt)
+char *bitmap_list_string(struct printf_state *ps, unsigned long *bitmap)
 {
-	int nr_bits = max_t(int, spec.field_width, 0);
+	int nr_bits = max_t(int, ps->spec.field_width, 0);
 	/* current bit is 'cur', most recently seen range is [rbot, rtop] */
 	int cur, rbot, rtop;
 	bool first = true;
 
+	ps->spec = default_dec_spec;
 	rbot = cur = find_first_bit(bitmap, nr_bits);
 	while (cur < nr_bits) {
 		rtop = cur;
@@ -1036,24 +1036,24 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,
 			continue;
 
 		if (!first) {
-			if (buf < end)
-				*buf = ',';
-			buf++;
+			if (ps->buf < ps->end)
+				*ps->buf = ',';
+			ps->buf++;
 		}
 		first = false;
 
-		buf = number(buf, end, rbot, default_dec_spec);
+		printf_number(ps, rbot);
 		if (rbot < rtop) {
-			if (buf < end)
-				*buf = '-';
-			buf++;
+			if (ps->buf < ps->end)
+				*ps->buf = '-';
+			ps->buf++;
 
-			buf = number(buf, end, rtop, default_dec_spec);
+			printf_number(ps, rtop);
 		}
 
 		rbot = cur;
 	}
-	return buf;
+	return ps->buf;
 }
 
 static noinline_for_stack
@@ -1899,7 +1899,7 @@ char *pointer(struct printf_state *ps, void *ptr)
 	case 'b':
 		switch (fmt[1]) {
 		case 'l':
-			return bitmap_list_string(buf, end, ptr, spec, fmt);
+			return bitmap_list_string(ps, ptr);
 		default:
 			return bitmap_string(buf, end, ptr, spec, fmt);
 		}