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

index f0cc1d6e9356fe33ef9a625ab2dcdf2c7b9bf1ad..570bfe8dc465179d0a6bc99ef888904562d87235 100644 (file)
@@ -527,17 +527,17 @@ void printf_number(struct printf_state *ps, unsigned long long num)
 }
 
 static noinline_for_stack
-char *special_hex_number(char *buf, char *end, unsigned long long num, int size)
+char *special_hex_number(struct printf_state *ps, unsigned long long num,
+               int size)
 {
-       struct printf_spec spec;
+       ps->spec.type = FORMAT_TYPE_PTR;
+       ps->spec.field_width = 2 + 2 * size;    /* 0x + hex */
+       ps->spec.flags = SPECIAL | SMALL | ZEROPAD;
+       ps->spec.base = 16;
+       ps->spec.precision = -1;
 
-       spec.type = FORMAT_TYPE_PTR;
-       spec.field_width = 2 + 2 * size;        /* 0x + hex */
-       spec.flags = SPECIAL | SMALL | ZEROPAD;
-       spec.base = 16;
-       spec.precision = -1;
-
-       return number(buf, end, num, spec);
+       printf_number(ps, num);
+       return ps->buf;
 }
 
 static void move_right(char *buf, char *end, unsigned len, unsigned spaces)
@@ -805,10 +805,10 @@ char *symbol_string(struct printf_state *ps, void *ptr)
                sprint_symbol_no_offset(sym, value);
 
        printf_string(ps, sym);
-       return ps->buf;
 #else
-       return special_hex_number(ps->buf, ps->end, value, sizeof(void *));
+       special_hex_number(ps, value, sizeof(void *));
 #endif
+       return ps->buf;
 }
 
 static const struct printf_spec default_str_spec = {
@@ -1530,7 +1530,7 @@ char *netdev_bits(struct printf_state *ps, const void *addr)
                return ptr_to_id(ps->buf, ps->end, addr, ps->spec);
        }
 
-       return special_hex_number(ps->buf, ps->end, num, size);
+       return special_hex_number(ps, num, size);
 }
 
 static noinline_for_stack
@@ -1551,7 +1551,7 @@ char *address_val(struct printf_state *ps, const void *addr)
                break;
        }
 
-       return special_hex_number(ps->buf, ps->end, num, size);
+       return special_hex_number(ps, num, size);
 }
 
 static noinline_for_stack