* [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper
@ 2023-07-31 1:44 Atul Raut
2023-07-31 10:08 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Atul Raut @ 2023-07-31 1:44 UTC (permalink / raw)
To: cosmin.tanislav, lars, Michael.Hennerich, jic23
Cc: linux-iio, linux-kernel-mentees
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@gmail.com>
---
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,
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper
2023-07-31 1:44 [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Atul Raut
@ 2023-07-31 10:08 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-07-31 10:08 UTC (permalink / raw)
To: Atul Raut
Cc: cosmin.tanislav, lars, Michael.Hennerich, jic23, linux-iio,
linux-kernel-mentees
On Sun, 30 Jul 2023 18:44:06 -0700
Atul Raut <rauji.raut@gmail.com> 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@gmail.com>
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,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-31 10:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-31 1:44 [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Atul Raut
2023-07-31 10:08 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox