summaryrefslogtreecommitdiff
path: root/lib/tiny-printf.c
diff options
context:
space:
mode:
authorChristoph Niedermaier <cniedermaier@dh-electronics.com>2025-03-20 20:01:47 +0100
committerTom Rini <trini@konsulko.com>2025-04-08 16:23:27 -0600
commit51b8679b94ea22ffb91925cf56df1950fd4b0e12 (patch)
tree0f5df3e05accc33bbf2f10b4caac1ab6658e47af /lib/tiny-printf.c
parent9d9fbdab0e9664bff147109cc89ad2786f6ecd83 (diff)
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 <cniedermaier@dh-electronics.com> Reviewed-by: Tom Rini <trini@konsulko.com> Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'lib/tiny-printf.c')
-rw-r--r--lib/tiny-printf.c1
1 files changed, 1 insertions, 0 deletions
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);