Messages in this thread | | | Date | Wed, 28 Mar 2018 10:34:54 -0500 | From | Josh Poimboeuf <> | Subject | Re: [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
| |