tiny-printf: Improve %X formatting
PATCH v2 1/1 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.
---
Cc: Marek Vasut <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Benedikt Spranger <[email protected]>
Cc: Simon Glass <[email protected]>
Cc: John Ogness <[email protected]>
Cc: Jerome Forissier <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
--- lib/tiny-printf.c | 1 + 1 file changed, 1 insertion(+)
lib/tiny-printf.c +1 -0
@@ -284,6 +284,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 );
Signature · 1 line
2.30.2
Quoted 9 lines · Christoph Niedermaier
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 <[email protected]>
Signature · 1 line
Tom
Quoted 9 lines · Christoph Niedermaier
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 <[email protected]>
Quoted 9 lines · Christoph Niedermaier
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.[...]
Applied to u-boot/master, thanks!
[1/1] tiny-printf: Improve %X formatting
commit: 51b8679b94ea22ffb91925cf56df1950fd4b0e12
Signature · 1 line
Tom