Skip to content

Commit

Permalink
lib/vsprintf: Make dec_spec global
Browse files Browse the repository at this point in the history
There are places where default specification to print decimal numbers
is in use.

Make it global and convert existing users.

Link: http://lkml.kernel.org/r/20180216210711.79901-2-andriy.shevchenko@linux.intel.com
To: "Tobin C . Harding" <me@tobin.cc>
To: linux@rasmusvillemoes.dk
To: Joe Perches <joe@perches.com>
To: linux-kernel@vger.kernel.org
To: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
  • Loading branch information
Andy Shevchenko authored and Petr Mladek committed Apr 11, 2018
1 parent c604b40 commit ce0b491
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,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)
Expand Down Expand Up @@ -722,11 +727,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,
Expand Down Expand Up @@ -760,10 +760,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;
Expand Down Expand Up @@ -903,9 +903,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;
Expand All @@ -920,13 +917,13 @@ char *bitmap_list_string(char *buf, char *end, unsigned long *bitmap,
}
first = false;

buf = number(buf, end, rbot, spec);
buf = number(buf, end, rbot, default_dec_spec);
if (rbot < rtop) {
if (buf < end)
*buf = '-';
buf++;

buf = number(buf, end, rtop, spec);
buf = number(buf, end, rtop, default_dec_spec);
}

rbot = cur;
Expand Down

0 comments on commit ce0b491

Please sign in to comment.