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

From: Andy Shevchenko
Date: Wed Feb 28 2024 - 16:37:04 EST


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.

--
With Best Regards,
Andy Shevchenko