Re: [PATCH -next] iio: st_accel: Fix unused variable warning

From: Jonathan Cameron
Date: Sat Nov 02 2019 - 10:08:29 EST


On Sat, 2 Nov 2019 11:41:25 +0100
Ladislav Michl <ladis@xxxxxxxxxxxxxx> wrote:

> On Fri, Nov 01, 2019 at 09:47:41PM +0800, YueHaibing wrote:
> > drivers/iio/accel/st_accel_core.c:1005:44: warning:
> > mount_matrix_ext_info defined but not used [-Wunused-const-variable=]
> >
> > Move it to ifdef to mute this warning.
> >
> > Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
> > ---
> > drivers/iio/accel/st_accel_core.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> > index 2e37f8a..bba0717 100644
> > --- a/drivers/iio/accel/st_accel_core.c
> > +++ b/drivers/iio/accel/st_accel_core.c
> > @@ -1002,10 +1002,12 @@ get_mount_matrix(const struct iio_dev *indio_dev,
> > return adata->mount_matrix;
> > }
> >
> > +#ifdef CONFIG_ACPI
> > static const struct iio_chan_spec_ext_info mount_matrix_ext_info[] = {
> > IIO_MOUNT_MATRIX(IIO_SHARED_BY_ALL, get_mount_matrix),
>
> So now you do not get any warning for unused get_mount_matrix?
> (Then it would make more sense to put all that stuff under one ifdef
> and provide empty apply_acpi_orientation for non ACPI case)

Does the __maybe_unused marking make this go away?

I'd assume that the compiler will manage to drop this either way
but I guess we should check that.

ifdef magic is always harder to read and potentially fragile in the
long run. Here we simply want to indicate that in some build
configurations we might not use this.

Thanks,

Jonathan


>
> > { },
> > };
> > +#endif
> >
> > /* Read ST-specific _ONT orientation data from ACPI and generate an
> > * appropriate mount matrix.
> > --
> > 2.7.4
> >