From 23efd0804c0a869dfb1e78470f80a27251317b7e Mon Sep 17 00:00:00 2001 From: "Matthew Wilcox (Oracle)" Date: Tue, 19 Oct 2021 15:26:21 +0100 Subject: vsprintf: Make %pGp print the hex value All existing users of %pGp want the hex value as well as the decoded flag names. This looks awkward (passing the same parameter to printf twice), so move that functionality into the core. If we want, we can make that optional with flag arguments to %pGp in the future. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Yafang Shao Reviewed-by: Petr Mladek Signed-off-by: Petr Mladek Link: https://lore.kernel.org/r/20211019142621.2810043-6-willy@infradead.org --- lib/test_printf.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/test_printf.c') diff --git a/lib/test_printf.c b/lib/test_printf.c index d09993fca463..07309c45f327 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -609,10 +609,14 @@ page_flags_test(int section, int node, int zone, int last_cpupid, char *cmp_buf) { unsigned long values[] = {section, node, zone, last_cpupid, kasan_tag}; - unsigned long size = 0; + unsigned long size; bool append = false; int i; + for (i = 0; i < ARRAY_SIZE(values); i++) + flags |= (values[i] & pft[i].mask) << pft[i].shift; + + size = scnprintf(cmp_buf, BUF_SIZE, "%#lx(", flags); if (flags & PAGEFLAGS_MASK) { size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s", name); append = true; @@ -625,7 +629,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid, if (append) size += scnprintf(cmp_buf + size, BUF_SIZE - size, "|"); - flags |= (values[i] & pft[i].mask) << pft[i].shift; size += scnprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name); size += scnprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt, @@ -633,6 +636,8 @@ page_flags_test(int section, int node, int zone, int last_cpupid, append = true; } + snprintf(cmp_buf + size, BUF_SIZE - size, ")"); + test(cmp_buf, "%pGp", &flags); } -- cgit