lkml.org 
[lkml]   [2018]   [Feb]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] vsprintf: avoid misleading "(null)" for %px
Hi Petr,

On Wed, Feb 7, 2018 at 4:41 PM, Petr Mladek <pmladek@suse.com> wrote:
> On Wed 2018-02-07 16:11:13, Geert Uytterhoeven wrote:
>> On Wed, Feb 7, 2018 at 4:03 PM, Petr Mladek <pmladek@suse.com> wrote:
>> > [*] I made some archaeology:
>> >
>> > The "(null)" string was added by the commit d97106ab53f812910
>> > ("Make %p print '(null)' for NULL pointers").
>> >
>> > It was a generic solution to prevent eventual crashes, see
>> > https://lkml.kernel.org/r/1230979341-23029-1-git-send-email-xyzzy@speakeasy.org
>> >
>> > From this point, printing 00000000 for %px looks perfectly fine because
>> > it does not crash.
>> >
>> > In fact, it would have made perfect sense to print 00000000 for pure
>> > %p because it did not crash. But nobody has cared about the eventual
>> > confusion yet.
>> >
>> > I am not sure if it makes sense to change the pure %p handling
>> > now. Note that printing "(null)" has the advantage that we
>> > get this string instead of the hash ;-)
>>
>> Note that "(null)" is also used for printing strings, where you do dereference
>> the pointer, unlike for printing pointers.
>> In addition, "(null)" for strings is not just printed for real NULL
>> pointers, but
>> also for anything pointing within the first page of virtual memory.
>
> We are on the safe side. "(null)" for "%s" is handled
> separately, see string() function in lib/vsprintf.c.

I know.

> To make it clear. I was talking about "%p" format that is handled
> in the pointer() function in lib/vsprintf.c. The "(null)" makes
> sense only for the many modifiers that do deference of
> the pointer, e.g. "%pa", "%pE", "%ph". It makes less sense
> for the pure "%p" used without any modifier. Well, it actually
> started to makes some sense after we started printing
> the hash instead of the real pointer value.

Sure. I agree with all of that.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2018-02-07 16:48    [W:0.079 / U:34.864 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site