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

index b7cef6812819e454647562157ab3d5b527bd9348..a1e410f9be48a20eb6c91368ee6a1013391be0ae 100644 (file)
@@ -619,17 +619,17 @@ static void printf_string(struct printf_state *ps, const char *s)
 }
 
 static noinline_for_stack
-char *pointer_string(char *buf, char *end, const void *ptr,
-                    struct printf_spec spec)
+char *pointer_string(struct printf_state *ps, const void *ptr)
 {
-       spec.base = 16;
-       spec.flags |= SMALL;
-       if (spec.field_width == -1) {
-               spec.field_width = 2 * sizeof(ptr);
-               spec.flags |= ZEROPAD;
+       ps->spec.base = 16;
+       ps->spec.flags |= SMALL;
+       if (ps->spec.field_width == -1) {
+               ps->spec.field_width = 2 * sizeof(ptr);
+               ps->spec.flags |= ZEROPAD;
        }
 
-       return number(buf, end, (unsigned long int)ptr, spec);
+       printf_number(ps, (unsigned long int)ptr);
+       return ps->buf;
 }
 
 /* Make pointers available for printing early in the boot sequence. */
@@ -698,8 +698,7 @@ static char *ptr_to_id(struct printf_state *ps, 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(ps->buf, ps->end, (const void *)hashval,
-                               ps->spec);
+               return pointer_string(ps, (const void *)hashval);
        }
 
        if (static_branch_unlikely(&not_filled_random_ptr_key)) {
@@ -719,8 +718,7 @@ static char *ptr_to_id(struct printf_state *ps, const void *ptr)
 #else
        hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key);
 #endif
-       return pointer_string(ps->buf, ps->end, (const void *)hashval,
-                       ps->spec);
+       return pointer_string(ps, (const void *)hashval);
 }
 
 static noinline_for_stack
@@ -1514,7 +1512,7 @@ char *restricted_pointer(struct printf_state *ps, const void *ptr)
                break;
        }
 
-       return pointer_string(ps->buf, ps->end, ptr, ps->spec);
+       return pointer_string(ps, ptr);
 }
 
 static noinline_for_stack
@@ -1984,7 +1982,7 @@ char *pointer(struct printf_state *ps, void *ptr)
                }
                break;
        case 'x':
-               return pointer_string(buf, end, ptr, spec);
+               return pointer_string(ps, ptr);
        }
 
        /* default is to _not_ leak addresses, hash before printing */