From: Christoph Niedermaier Date: Thu, 20 Mar 2025 19:01:47 +0000 (+0100) Subject: tiny-printf: Improve %X formatting X-Git-Tag: v2025.07-rc1~115 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=51b8679b94ea22ffb91925cf56df1950fd4b0e12;p=pandora-u-boot.git tiny-printf: Improve %X formatting If tiny printf is used with 0x%08X (upper case X) the output is always 0x00000000. It could be confusing if upper case instead of lower case is used intentionally or accidentally because the actual value is not output. To avoid this confusion, treat output of %X as %x. As a compromise for tiny printf, the hex value is then output correctly, but in lower case. This is done to keep it tiny printf small. Signed-off-by: Christoph Niedermaier Reviewed-by: Tom Rini Reviewed-by: Marek Vasut --- diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c index faf55d7f327..da2063d27c9 100644 --- a/lib/tiny-printf.c +++ b/lib/tiny-printf.c @@ -285,6 +285,7 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va) islong = true; /* no break */ case 'x': + case 'X': if (islong) { num = va_arg(va, unsigned long); div = 1UL << (sizeof(long) * 8 - 4);