From 51b8679b94ea22ffb91925cf56df1950fd4b0e12 Mon Sep 17 00:00:00 2001 From: Christoph Niedermaier Date: Thu, 20 Mar 2025 20:01:47 +0100 Subject: [PATCH] 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 --- lib/tiny-printf.c | 1 + 1 file changed, 1 insertion(+) 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); -- 2.39.5