aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2016-01-05 09:30:57 -0700
committerSimon Glass <sjg@chromium.org>2016-01-20 19:06:22 -0700
commit74b1320ae535b9dfe6fb7a86e05a8787e503f59c (patch)
tree55d356417d5a0e3f8f1b3823914306d78f71092d /lib
parent5589a8182957054f8ac4ec3d91492710e718e44d (diff)
downloadu-boot-74b1320ae535b9dfe6fb7a86e05a8787e503f59c.zip
u-boot-74b1320ae535b9dfe6fb7a86e05a8787e503f59c.tar.gz
u-boot-74b1320ae535b9dfe6fb7a86e05a8787e503f59c.tar.bz2
tiny-printf: Always print zeroes
At present this does not print zero values in numeric format (hex and decimal). Add a special case for this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/tiny-printf.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index efe5c25..a06abed 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -82,13 +82,21 @@ int vprintf(const char *fmt, va_list va)
num = -(int)num;
out('-');
}
- for (div = 1000000000; div; div /= 10)
- div_out(&num, div);
+ if (!num) {
+ out_dgt(0);
+ } else {
+ for (div = 1000000000; div; div /= 10)
+ div_out(&num, div);
+ }
break;
case 'x':
num = va_arg(va, unsigned int);
- for (div = 0x10000000; div; div /= 0x10)
- div_out(&num, div);
+ if (!num) {
+ out_dgt(0);
+ } else {
+ for (div = 0x10000000; div; div /= 0x10)
+ div_out(&num, div);
+ }
break;
case 'c':
out((char)(va_arg(va, int)));