From: Matthew Wilcox Date: Wed, 19 Dec 2018 15:33:10 +0000 (-0500) Subject: printf: Convert ptr_to_id to printf_state X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=451b6db6f09aa2af817dc3b5b5f45b867a66453c;p=users%2Fwilly%2Flinux.git printf: Convert ptr_to_id to printf_state Signed-off-by: Matthew Wilcox --- diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 46dffe1d7108..bce6174074c2 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -690,8 +690,7 @@ static int __init initialize_ptr_random(void) early_initcall(initialize_ptr_random); /* Maps a pointer to a 32 bit unique identifier. */ -static char *ptr_to_id(char *buf, char *end, const void *ptr, - struct printf_spec spec) +static char *ptr_to_id(struct printf_state *ps, const void *ptr) { const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)"; unsigned long hashval; @@ -699,13 +698,15 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr, /* When debugging early boot use non-cryptographically secure hash. */ if (unlikely(debug_boot_weak_hash)) { hashval = hash_long((unsigned long)ptr, 32); - return pointer_string(buf, end, (const void *)hashval, spec); + return pointer_string(ps->buf, ps->end, (const void *)hashval, + ps->spec); } if (static_branch_unlikely(¬_filled_random_ptr_key)) { - spec.field_width = 2 * sizeof(ptr); + ps->spec.field_width = 2 * sizeof(ptr); /* string length must be less than default_width */ - return string(buf, end, str, spec); + printf_string(ps, str); + return ps->buf; } #ifdef CONFIG_64BIT @@ -718,7 +719,8 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr, #else hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key); #endif - return pointer_string(buf, end, (const void *)hashval, spec); + return pointer_string(ps->buf, ps->end, (const void *)hashval, + ps->spec); } static noinline_for_stack @@ -1527,7 +1529,7 @@ char *netdev_bits(struct printf_state *ps, const void *addr) size = sizeof(netdev_features_t); break; default: - return ptr_to_id(ps->buf, ps->end, addr, ps->spec); + return ptr_to_id(ps, addr); } return special_hex_number(ps, num, size); @@ -1569,7 +1571,7 @@ char *clock(struct printf_state *ps, struct clk *clk) printf_string(ps, __clk_get_name(clk)); return ps->buf; #else - return ptr_to_id(ps->buf, ps->end, clk, ps->spec); + return ptr_to_id(ps, clk); #endif } } @@ -1986,7 +1988,7 @@ char *pointer(struct printf_state *ps, void *ptr) } /* default is to _not_ leak addresses, hash before printing */ - return ptr_to_id(buf, end, ptr, spec); + return ptr_to_id(ps, ptr); } void printf_pointer(struct printf_state *ps, void *ptr)