[PATCH v2 03/11] lib/vsprintf: make default_str_spec global
From: Andy Shevchenko
Date: Thu Jan 14 2016 - 17:27:35 EST
There will be place where default specification to print string is used.
Make it global and convert existing user.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
lib/vsprintf.c | 35 ++++++++++++++++++-----------------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 53a6e7c..f0789e3 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -671,6 +671,12 @@ static const struct printf_spec default_dec_spec = {
.precision = -1,
};
+static const struct printf_spec default_str_spec = {
+ .field_width = -1,
+ .precision = 10,
+ .flags = LEFT,
+};
+
static noinline_for_stack
char *resource_string(char *buf, char *end, struct resource *res,
struct printf_spec spec, const char *fmt)
@@ -700,11 +706,6 @@ char *resource_string(char *buf, char *end, struct resource *res,
.precision = -1,
.flags = SMALL | ZEROPAD,
};
- static const struct printf_spec str_spec = {
- .field_width = -1,
- .precision = 10,
- .flags = LEFT,
- };
static const struct printf_spec flag_spec = {
.base = 16,
.precision = -1,
@@ -726,27 +727,27 @@ char *resource_string(char *buf, char *end, struct resource *res,
*p++ = '[';
if (res->flags & IORESOURCE_IO) {
- p = string(p, pend, "io ", str_spec);
+ p = string(p, pend, "io ", default_str_spec);
specp = &io_spec;
} else if (res->flags & IORESOURCE_MEM) {
- p = string(p, pend, "mem ", str_spec);
+ p = string(p, pend, "mem ", default_str_spec);
specp = &mem_spec;
} else if (res->flags & IORESOURCE_IRQ) {
- p = string(p, pend, "irq ", str_spec);
+ p = string(p, pend, "irq ", default_str_spec);
specp = &default_dec_spec;
} else if (res->flags & IORESOURCE_DMA) {
- p = string(p, pend, "dma ", str_spec);
+ p = string(p, pend, "dma ", default_str_spec);
specp = &default_dec_spec;
} else if (res->flags & IORESOURCE_BUS) {
- p = string(p, pend, "bus ", str_spec);
+ p = string(p, pend, "bus ", default_str_spec);
specp = &bus_spec;
} else {
- p = string(p, pend, "??? ", str_spec);
+ p = string(p, pend, "??? ", default_str_spec);
specp = &mem_spec;
decode = 0;
}
if (decode && res->flags & IORESOURCE_UNSET) {
- p = string(p, pend, "size ", str_spec);
+ p = string(p, pend, "size ", default_str_spec);
p = number(p, pend, resource_size(res), *specp);
} else {
p = number(p, pend, res->start, *specp);
@@ -757,15 +758,15 @@ char *resource_string(char *buf, char *end, struct resource *res,
}
if (decode) {
if (res->flags & IORESOURCE_MEM_64)
- p = string(p, pend, " 64bit", str_spec);
+ p = string(p, pend, " 64bit", default_str_spec);
if (res->flags & IORESOURCE_PREFETCH)
- p = string(p, pend, " pref", str_spec);
+ p = string(p, pend, " pref", default_str_spec);
if (res->flags & IORESOURCE_WINDOW)
- p = string(p, pend, " window", str_spec);
+ p = string(p, pend, " window", default_str_spec);
if (res->flags & IORESOURCE_DISABLED)
- p = string(p, pend, " disabled", str_spec);
+ p = string(p, pend, " disabled", default_str_spec);
} else {
- p = string(p, pend, " flags ", str_spec);
+ p = string(p, pend, " flags ", default_str_spec);
p = number(p, pend, res->flags, flag_spec);
}
*p++ = ']';
--
2.6.4