]> git.sur5r.net Git - u-boot/commitdiff
tiny-printf: Always print zeroes
authorSimon Glass <sjg@chromium.org>
Tue, 5 Jan 2016 16:30:57 +0000 (09:30 -0700)
committerSimon Glass <sjg@chromium.org>
Thu, 21 Jan 2016 02:06:22 +0000 (19:06 -0700)
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>
lib/tiny-printf.c

index efe5c25a59381f1f58f01c65818cb67fdf5a7b00..a06abed49590ecbdbb8017f4df68e0c2208f3016 100644 (file)
@@ -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)));