lkml.org 
[lkml]   [2018]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] debugfs: Check return value of debugfs_real_fops() for NULL
On Wed, Mar 28, 2018 at 10:30:51AM -0500, Josh Poimboeuf wrote:
> On Wed, Mar 28, 2018 at 07:47:53AM -0700, Manoj Gupta wrote:
> > Please note that there is nothing wrong in the generated code, just
> > that it confuses objtool.
> > Clang has simply omitted the statement where NULL is returned since
> > the pointer was always dereferenced post inlining.
>
> ... but returning NULL would be far more sane than falling through to
> the next function.

Or, as the case may be, oopsing at the point of failure.


> > Note that GCC will also remove the NULL pointers if it knows that the
> > pointer is dereferenced.
> > Here is an example.
> >
> > void null_check(int *P) {
> > int deref = *P;
> > if (P == 0) // GCC won't check the condition.
> > return;
> > *P = 4;
> > }
> >
> > Compiling with gcc -O2 gives:
> > movl $4, (%rdi)
> > ret
>
> This is why we use -fno-delete-null-pointer-checks.

--
Josh

\
 
 \ /
  Last update: 2018-03-28 17:35    [W:0.065 / U:1.200 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site