Re: [PATCH v4 3/8] iio: core: NULLify private pointer when there is no private data

From: Jonathan Cameron
Date: Sun Mar 03 2024 - 07:46:55 EST


On Wed, 28 Feb 2024 23:36:43 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

> On Wed, Feb 28, 2024 at 03:06:42PM -0600, David Lechner wrote:
> > On Wed, Feb 28, 2024 at 2:50 PM Andy Shevchenko
> > <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> ...
>
> > > - indio_dev->priv = (char *)iio_dev_opaque +
> > > - ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN);
> > > +
> > > + if (sizeof_priv)
> > > + indio_dev->priv = (char *)iio_dev_opaque +
> > > + ALIGN(sizeof(struct iio_dev_opaque), IIO_DMA_MINALIGN);
> > > + else
> > > + indio_dev->priv = NULL;
> >
> > Do we actually need the else branch here since we use kzalloc() and
> > therefore indio_dev->priv should already be NULL?
>
> This is more robust, but I'm okay to drop this. Up to Jonathan.
>

Given the allocation is just above here fine to drop the else in this
I think.