[PATCH] tiny-printf: Support %i

Tom Rini trini at konsulko.com
Tue Apr 14 01:27:11 CEST 2020


On Fri, Apr 10, 2020 at 08:54:49PM +0200, Marek Vasut wrote:

> The most basic printf("%i", value) formating string was missing,
> add it for the sake of convenience.
> 
> Signed-off-by: Marek Vasut <marex at denx.de>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Stefan Roese <sr at denx.de>
> ---
>  lib/tiny-printf.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
> index 1138c7012a..8fc7e48d99 100644
> --- a/lib/tiny-printf.c
> +++ b/lib/tiny-printf.c
> @@ -242,6 +242,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
>  				goto abort;
>  			case 'u':
>  			case 'd':
> +			case 'i':
>  				div = 1000000000;
>  				if (islong) {
>  					num = va_arg(va, unsigned long);
> @@ -251,7 +252,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
>  					num = va_arg(va, unsigned int);
>  				}
>  
> -				if (ch == 'd') {
> +				if (ch != 'u') {
>  					if (islong && (long)num < 0) {
>  						num = -(long)num;
>  						out(info, '-');

How much does the size change and where do we see this as a problem?
Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200413/bd53805c/attachment.sig>


More information about the U-Boot mailing list