Re: [PATCH] vsprintf: don't obfuscate NULL and error pointers

From: Linus Torvalds
Date: Tue Feb 18 2020 - 14:39:04 EST


On Tue, Feb 18, 2020 at 11:31 AM Adam Borowski <kilobyte@xxxxxxxxxx> wrote:
>
> Either "0" or "NULL" (or "â" if you allow cp437-subset Unicode ) wouldn't
> cause such confusion.

An all-uppercase "NULL" probably matches the error code printout
syntax better too, and is more clearly a pointer.

And with %pe you can't assume columnar output anyway (unless you
explicitly ask for some width), so the length of the output cannot
matter.

So yeah, I agree. To extend on Ilya's example:

ptr error-ptr NULL
%p: 0000000001f8cc5b fffffffffffffff2 0000000000000000
%pK, kptr = 0: 0000000001f8cc5b fffffffffffffff2 0000000000000000
%px: ffff888048c04020 fffffffffffffff2 0000000000000000
%pK, kptr = 1: ffff888048c04020 fffffffffffffff2 0000000000000000
%pK, kptr = 2: 0000000000000000 0000000000000000 0000000000000000
%p: 0000000001f8cc5b -EFAULT NULL

would seem to be a sane output format. Hmm?

Linus