lkml.org 
[lkml]   [2015]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 1/5] firmware: fix __getname() missing failure check
From
On Tue, May 12, 2015 at 11:30 AM, Luis R. Rodriguez
<mcgrof@do-not-panic.com> wrote:
> +
> + path = __getname();
> + if (unlikely(!path))
> + return PTR_ERR(path);

This makes no sense.

PTR_ERR() on NULL is an insane operation. It's a very non-intuitive
and misleading way of writing "0".

So not only is that "return 0;", that's not likely what you want _anyway_.

If you intended to return an error, you should just have done so, eg

if (unlikely(!path))
return -ENOMEM;

which actually does something sane, and is more readable.

PTR_ERR() is for when you get an error pointer, so a sequence like

if (IS_ERR(ptr))
return PTR_ERR(ptr);

is sensible (it checks whether the ptr has an error value in it, and
then returns the integer error value of the pointer).

But for a NULL pointer? No.

Linus


\
 
 \ /
  Last update: 2015-05-12 22:41    [W:0.069 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site