[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1452810221-116505-3-git-send-email-andriy.shevchenko@linux.intel.com>
Date: Fri, 15 Jan 2016 00:23:32 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Robert Elliott <elliott@....com>,
Matt Fleming <matt@...eblueprint.co.uk>,
Andrew Morton <akpm@...ux-foundation.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Brian Norris <computersforpeace@...il.com>,
Hariprasad S <hariprasad@...lsio.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 02/11] lib/vsprintf: make default_dec_spec global
There are places where default specification to print decimal numbers is used.
Make it global and convert existing users.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
lib/test_printf.c | 5 +++--
lib/vsprintf.c | 21 +++++++++------------
2 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/lib/test_printf.c b/lib/test_printf.c
index 4f6ae60..fd985f6 100644
--- a/lib/test_printf.c
+++ b/lib/test_printf.c
@@ -376,9 +376,10 @@ large_bitmap(void)
if (!bits)
return;
- bitmap_set(bits, 1, 20);
+ bitmap_set(bits, 0, 1);
+ bitmap_set(bits, 2, 20);
bitmap_set(bits, 60000, 15);
- test("1-20,60000-60014", "%*pbl", nbits, bits);
+ test("0,2-21,60000-60014", "%*pbl", nbits, bits);
kfree(bits);
}
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index fe6ffe3..53a6e7c 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -666,6 +666,11 @@ char *symbol_string(char *buf, char *end, void *ptr,
#endif
}
+static const struct printf_spec default_dec_spec = {
+ .base = 10,
+ .precision = -1,
+};
+
static noinline_for_stack
char *resource_string(char *buf, char *end, struct resource *res,
struct printf_spec spec, const char *fmt)
@@ -695,11 +700,6 @@ char *resource_string(char *buf, char *end, struct resource *res,
.precision = -1,
.flags = SMALL | ZEROPAD,
};
- static const struct printf_spec dec_spec = {
- .base = 10,
- .precision = -1,
- .flags = 0,
- };
static const struct printf_spec str_spec = {
.field_width = -1,
.precision = 10,
@@ -733,10 +733,10 @@ char *resource_string(char *buf, char *end, struct resource *res,
specp = &mem_spec;
} else if (res->flags & IORESOURCE_IRQ) {
p = string(p, pend, "irq ", str_spec);
- specp = &dec_spec;
+ specp = &default_dec_spec;
} else if (res->flags & IORESOURCE_DMA) {
p = string(p, pend, "dma ", str_spec);
- specp = &dec_spec;
+ specp = &default_dec_spec;
} else if (res->flags & IORESOURCE_BUS) {
p = string(p, pend, "bus ", str_spec);
specp = &bus_spec;
@@ -866,9 +866,6 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,
int cur, rbot, rtop;
bool first = true;
- /* reused to print numbers */
- spec = (struct printf_spec){ .base = 10 };
-
rbot = cur = find_first_bit(bitmap, nr_bits);
while (cur < nr_bits) {
rtop = cur;
@@ -880,10 +877,10 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,
buf = put_one_char(buf, end, ',');
first = false;
- buf = number(buf, end, rbot, spec);
+ buf = number(buf, end, rbot, default_dec_spec);
if (rbot < rtop) {
buf = put_one_char(buf, end, '-');
- buf = number(buf, end, rtop, spec);
+ buf = number(buf, end, rtop, default_dec_spec);
}
rbot = cur;
--
2.6.4
Powered by blists - more mailing lists