Message ID | 1351624792-13853-1-git-send-email-wd@denx.de |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
Hi Wolfgang, On Tue, Oct 30, 2012 at 2:19 PM, Wolfgang Denk <wd@denx.de> wrote: > 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 <wd@denx.de> > --- Acked-by: Joe Hershberger <joe.hershberger@ni.com>
On Tue, Oct 30, 2012 at 02:23:17PM -0500, Joe Hershberger wrote: > Hi Wolfgang, > > On Tue, Oct 30, 2012 at 2:19 PM, Wolfgang Denk <wd@denx.de> wrote: > > 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 <wd@denx.de> > > --- > > Acked-by: Joe Hershberger <joe.hershberger@ni.com> Applied to u-boot/master, thanks!
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d762763..dd13bca 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) {
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 <wd@denx.de> --- lib/vsprintf.c | 6 ++++++ 1 file changed, 6 insertions(+)