Re: [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 30 Jul 2023 18:44:06 -0700
Atul Raut <rauji.raut@xxxxxxxxx> wrote:

Patch title should mention the device

iio: accel: adxl367: ...


> Replacing zero-length arrays with C99 flexible-array
> members since they are obsolete.
> Use the new DECLARE_FLEX_ARRAY() auxiliary macro instead
> of defining a zero-length array.
> 
> This fixes warnings such as:
> ./drivers/iio/accel/adxl367_spi.c:38:6-17: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
> 
> Signed-off-by: Atul Raut <rauji.raut@xxxxxxxxx>

It isn't a variable length array so the heuristic that provided that warning is wrong.

It could be switched to a u8 but then the code would be slightly harder to read
as the functions it is being passed are typically used with arrays - this one just
happens to only be one element long.

Jonathan



> ---
>  drivers/iio/accel/adxl367_spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/adxl367_spi.c b/drivers/iio/accel/adxl367_spi.c
> index 118c894015a5..9dc61cb45fc5 100644
> --- a/drivers/iio/accel/adxl367_spi.c
> +++ b/drivers/iio/accel/adxl367_spi.c
> @@ -35,7 +35,7 @@ struct adxl367_spi_state {
>  	 */
>  	u8			reg_write_tx_buf[1] __aligned(IIO_DMA_MINALIGN);
>  	u8			reg_read_tx_buf[2];
> -	u8			fifo_tx_buf[1];
> +	DECLARE_FLEX_ARRAY(u8,			fifo_tx_buf);
>  };
>  
>  static int adxl367_read_fifo(void *context, __be16 *fifo_buf,




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux