mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-30 00:20:44 +09:00
tiny-printf: Reorder code to support %p
With a bit of code reordering we can support %p using the existing code for ulong. Move the %p code up and adjust the logic accordingly. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
dee74e6cc4
commit
831c161119
@ -157,7 +157,8 @@ static void ip4_addr_string(struct printf_info *info, u8 *addr)
|
|||||||
* decimal).
|
* decimal).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void pointer(struct printf_info *info, const char *fmt, void *ptr)
|
static void __maybe_unused pointer(struct printf_info *info, const char *fmt,
|
||||||
|
void *ptr)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
unsigned long num = (uintptr_t)ptr;
|
unsigned long num = (uintptr_t)ptr;
|
||||||
@ -266,6 +267,21 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
|
|||||||
div_out(info, &num, div);
|
div_out(info, &num, div);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
#ifdef DEBUG
|
||||||
|
pointer(info, fmt, va_arg(va, void *));
|
||||||
|
/*
|
||||||
|
* Skip this because it pulls in _ctype which is
|
||||||
|
* 256 bytes, and we don't generally implement
|
||||||
|
* pointer anyway
|
||||||
|
*/
|
||||||
|
while (isalnum(fmt[0]))
|
||||||
|
fmt++;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
islong = true;
|
||||||
|
/* no break */
|
||||||
|
#endif
|
||||||
case 'x':
|
case 'x':
|
||||||
if (islong) {
|
if (islong) {
|
||||||
num = va_arg(va, unsigned long);
|
num = va_arg(va, unsigned long);
|
||||||
@ -287,18 +303,6 @@ static int _vprintf(struct printf_info *info, const char *fmt, va_list va)
|
|||||||
case 's':
|
case 's':
|
||||||
p = va_arg(va, char*);
|
p = va_arg(va, char*);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
|
||||||
pointer(info, fmt, va_arg(va, void *));
|
|
||||||
/*
|
|
||||||
* Skip this because it pulls in _ctype which is
|
|
||||||
* 256 bytes, and we don't generally implement
|
|
||||||
* pointer anyway
|
|
||||||
*/
|
|
||||||
#ifdef DEBUG
|
|
||||||
while (isalnum(fmt[0]))
|
|
||||||
fmt++;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case '%':
|
case '%':
|
||||||
out(info, '%');
|
out(info, '%');
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user