From 471d7128e07dd1bf8d2e06219717a10d5bf86299 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Wed, 19 Dec 2018 10:25:44 -0500 Subject: [PATCH] printf: Convert special_hex_number to printf_state Signed-off-by: Matthew Wilcox --- lib/vsprintf.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index f0cc1d6e9356..570bfe8dc465 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -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 -- 2.50.1