[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YzbdmJvcPiYAIalt@alley>
Date: Fri, 30 Sep 2022 14:14:16 +0200
From: Petr Mladek <pmladek@...e.com>
To: Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <senozhatsky@...omium.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
linux-kernel@...r.kernel.org, kernel@...gutronix.de
Subject: Re: [PATCH] printf: Emit "SUCCESS" if NULL is passed for %pe
On Fri 2022-09-30 13:10:50, Uwe Kleine-König wrote:
> For code that emits a string representing a usual return value it's
> convenient to have a 0 result in a string representation of success
> instead of "00000000".
Does it really always mean success, please?
IMHO, if a function returns a pointer then typically only a valid
pointer means success. Error code means some reasonable explanation
of the failure. And NULL should never happen.
For example:
struct bla *find_bla(int key)
{
struct bla *b;
/* Try to get bla using the given key */
...
if (succeded)
return b;
/* Did not find bla for the given key */
return -EINVAL;
}
It might be used:
int process_bla()
{
struct bla *b;
b = get_bla();
if (IS_ERR(b))
return PTR_ERR(b);
/* do something with b */
...
}
If get_bla() returns NULL then it means a super fault. It means
that get_bla() failed and did not know why.
IMHO, this patch might do more harm than good.
Best Regards,
Petr
Powered by blists - more mailing lists