]> www.infradead.org Git - users/willy/linux.git/commitdiff
printf: Convert bitmap_list_string to printf_state
authorMatthew Wilcox <willy@infradead.org>
Wed, 19 Dec 2018 15:44:30 +0000 (10:44 -0500)
committerMatthew Wilcox <willy@infradead.org>
Wed, 19 Dec 2018 15:44:30 +0000 (10:44 -0500)
Signed-off-by: Matthew Wilcox <willy@infradead.org>
lib/vsprintf.c

index a1e410f9be48a20eb6c91368ee6a1013391be0ae..4468bbcdc1423e659130b94243b10613b59a72ef 100644 (file)
@@ -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);
                }