lkml.org 
[lkml]   [2022]   [Sep]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2022-09-30 14:14    [W:0.058 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site