[lkml]   [2021]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] staging: android: Remove set but unused variable in ashmem.c
On Friday, July 23, 2021 10:14:46 PM CEST Suren Baghdasaryan wrote:
> On Fri, Jul 23, 2021 at 1:05 PM Fabio M. De Francesco
> <> wrote:
> > Remove variable 'inode' tnat is set but unused. Issue detected
> > by building with warning option -Wunused-but-set-variable.
> >
> > [...]
> >
> > - inode = file_inode(vmfile);
> >
> > lockdep_set_class(&inode->i_rwsem,
> How about its usage in the above lockdep_set_class(&inode->i_rwsem,
> ...) call?

I'm sorry. I didn't notice that 'inode' is used soon after assignment, just in
the line that follows it. I was also too confident that rebuilding the driver
would have triggered an error if it is used somewhere else. I was obviously

Furthermore, I usually automatically search with grep or other tools for other
occurrences of a symbol in the function and the file, but this time I must
have forgotten to do that.

> I'm guessing you are building with CONFIG_LOCKDEP=n.

Actually my .config sets CONFIG_LOCKDEP_SUPPORT=y. Did you refer to this?
There is no CONFIG_LOCKDEP in the file.

I've just run "make clean && make C=2 -j8 drivers/staging/android/ W=1" one
more time and it still builds. How is it possible that the code builds
correctly with my configuration?

This is the output (the last two lines) of 'make':

CC drivers/staging/android/ashmem.o
AR drivers/staging/android/built-in.

There are no errors or warnings, even with that "lockdep_set_class(&inode-
>i_rwsem, &backing_shmem_inode_class);" left as-is after 'inode' removal.

I really can't understand what I'm missing.

> Have you tried adding __maybe_unused in inode variable definition to
> get rid of the warning?
Actually, I didn't know that directive that you mention. I'll read the
documentation and, if and where suited, I'll use it.


> > [...]
> > --
> > 2.32.0

 \ /
  Last update: 2021-07-24 09:50    [W:0.049 / U:1.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site