From: Jonathan Cameron via Linux-kernel-mentees <linux-kernel-mentees@lists.linuxfoundation.org>
To: Atul Raut <rauji.raut@gmail.com>
Cc: lars@metafoo.de, Michael.Hennerich@analog.com,
cosmin.tanislav@analog.com, linux-iio@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org, jic23@kernel.org
Subject: Re: [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper
Date: Mon, 31 Jul 2023 11:08:46 +0100 [thread overview]
Message-ID: <20230731110846.00004176@Huawei.com> (raw)
In-Reply-To: <20230731014406.22810-1-rauji.raut@gmail.com>
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,
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Atul Raut <rauji.raut@gmail.com>
Cc: <cosmin.tanislav@analog.com>, <lars@metafoo.de>,
<Michael.Hennerich@analog.com>, <jic23@kernel.org>,
<linux-iio@vger.kernel.org>,
<linux-kernel-mentees@lists.linuxfoundation.org>
Subject: Re: [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper
Date: Mon, 31 Jul 2023 11:08:46 +0100 [thread overview]
Message-ID: <20230731110846.00004176@Huawei.com> (raw)
In-Reply-To: <20230731014406.22810-1-rauji.raut@gmail.com>
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,
next prev parent reply other threads:[~2023-07-31 10:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-31 1:44 [PATCH] iio: accel: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper Atul Raut
2023-07-31 1:44 ` Atul Raut
2023-07-31 10:08 ` Jonathan Cameron via Linux-kernel-mentees [this message]
2023-07-31 10:08 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230731110846.00004176@Huawei.com \
--to=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=cosmin.tanislav@analog.com \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=rauji.raut@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.