[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180216192806.68914-2-andriy.shevchenko@linux.intel.com>
Date: Fri, 16 Feb 2018 21:28:01 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: "Tobin C. Harding" <me@...in.cc>, linux@...musvillemoes.dk,
Petr Mladek <pmladek@...e.com>, Joe Perches <joe@...ches.com>,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v1 2/7] lib/vsprintf: Deduplicate pointer_string()
There is an exact code at the end of ptr_to_id().
Replace it by calling pointer_string() directly.
This is followup to the commit
ad67b74d2469 ("printk: hash addresses printed with %p").
Cc: Tobin C. Harding <me@...in.cc>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
lib/vsprintf.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d7a708f82559..b6d254723828 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -1697,10 +1697,9 @@ early_initcall(initialize_ptr_random);
static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
{
unsigned long hashval;
- const int default_width = 2 * sizeof(ptr);
if (unlikely(!have_filled_random_ptr_key)) {
- spec.field_width = default_width;
+ spec.field_width = 2 * sizeof(ptr);
/* string length must be less than default_width */
return string(buf, end, "(ptrval)", spec);
}
@@ -1715,15 +1714,7 @@ static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
#else
hashval = (unsigned long)siphash_1u32((u32)ptr, &ptr_key);
#endif
-
- spec.flags |= SMALL;
- if (spec.field_width == -1) {
- spec.field_width = default_width;
- spec.flags |= ZEROPAD;
- }
- spec.base = 16;
-
- return number(buf, end, hashval, spec);
+ return pointer_string(buf, end, (const void *)hashval, spec);
}
/*
--
2.15.1
Powered by blists - more mailing lists