From d266f669252a5ebd7e9b940743ec7d05cdbd4061 Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Tue, 30 Oct 2012 09:19:52 +0000 Subject: lib/vsprintf.c: don't special-case pointers to address null The %p format of printf() would print a pointer to address null as "(null)". This makes sense in a real OS where a NULL pointer must never be dereferenced, but this is a bootloader, and there are cases where accessing the data at address null makes perfect sense. Remove the special case in lib/vsprintf.c using "#if 0" with a comment to make clear this was an intentional change and to stop re-adding this code. Signed-off-by: Wolfgang Denk Acked-by: Joe Hershberger --- lib/vsprintf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/vsprintf.c') diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7627632d0a..dd13bca5a73 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -495,9 +495,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field_width, int precision, int flags) { + /* + * Being a boot loader, we explicitly allow pointers to + * (physical) address null. + */ +#if 0 if (!ptr) return string(buf, end, "(null)", field_width, precision, flags); +#endif #ifdef CONFIG_CMD_NET switch (*fmt) { -- cgit v1.2.3 From 0eb257683ded98431d6c30b360b7bd37235f518d Mon Sep 17 00:00:00 2001 From: Kim Phillips Date: Mon, 29 Oct 2012 13:34:36 +0000 Subject: lib/vsprintf.c: sparse fixes vsprintf.c:31:12: warning: symbol 'hex_asc' was not declared. Should it be static? vsprintf.c:398:18: warning: Using plain integer as NULL pointer Signed-off-by: Kim Phillips --- lib/vsprintf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/vsprintf.c') diff --git a/lib/vsprintf.c b/lib/vsprintf.c index dd13bca5a73..b7a79c0e0c9 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -28,7 +28,7 @@ /* some reluctance to put this into a new limits.h, so it is here */ #define INT_MAX ((int)(~0U>>1)) -const char hex_asc[] = "0123456789abcdef"; +static const char hex_asc[] = "0123456789abcdef"; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] #define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4] @@ -395,7 +395,7 @@ static char *string(char *buf, char *end, char *s, int field_width, { int len, i; - if (s == 0) + if (s == NULL) s = ""; len = strnlen(s, precision); -- cgit v1.2.3