From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefan Roese Date: Tue, 5 Jan 2016 18:08:18 +0100 Subject: [U-Boot] [PATCH 01/18] tiny-printf: Always print zeroes In-Reply-To: <1452011474-15207-2-git-send-email-sjg@chromium.org> References: <1452011474-15207-1-git-send-email-sjg@chromium.org> <1452011474-15207-2-git-send-email-sjg@chromium.org> Message-ID: <568BF882.6050009@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 05.01.2016 17:30, Simon Glass wrote: > 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 > --- > > lib/tiny-printf.c | 16 ++++++++++++---- > 1 file 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))); > Reviewed-by: Stefan Roese Thanks, Stefan