Thread (18 messages) 18 messages, 5 authors, 2020-02-24

Re: [PATCH] vsprintf: sanely handle NULL passed to %pe

From: Ilya Dryomov <idryomov@gmail.com>
Date: 2020-02-19 11:29:35
Also in: lkml

On Wed, Feb 19, 2020 at 12:25 PM Andy Shevchenko
[off-list ref] wrote:
On Wed, Feb 19, 2020 at 1:21 PM Ilya Dryomov [off-list ref] wrote:
quoted
On Wed, Feb 19, 2020 at 9:21 AM Rasmus Villemoes
[off-list ref] wrote:
quoted
Extend %pe to pretty-print NULL in addition to ERR_PTRs,
i.e. everything IS_ERR_OR_NULL().
...
quoted
quoted
+       [0] = "NULL",
quoted
quoted
+       test("[NULL]", "[%pe]", NULL);
quoted
FWIW I was about to post a patch that just special cases NULL here.

I think changing errname() to return "NULL" for 0 is overkill.
People will sooner or later discover that function and start using it
in contexts that don't have anything to do with pointers.  Returning
_some_ string for 0 (instead of NULL) makes it very close to standard
strerror(), and "NULL" for 0 (i.e. success) seems rather odd.
%pe is specifically for _pointers_. I don't see a point in your comment.
%pe is for pointers, but errname() in lib/errname.c will likely grow
more users in the future.

Thanks,

                Ilya
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help