kernel: backport v6.6 nvmem changes
[openwrt/openwrt.git] / target / linux / generic / backport-5.15 / 819-v6.6-0013-nvmem-u-boot-env-Replace-zero-length-array-with-DECL.patch
1 From c32f2186acc9abb4d766361255d7ddf07d15eeb2 Mon Sep 17 00:00:00 2001
2 From: Atul Raut <rauji.raut@gmail.com>
3 Date: Sun, 30 Jul 2023 15:39:15 -0700
4 Subject: [PATCH] nvmem: u-boot-env:: Replace zero-length array with
5 DECLARE_FLEX_ARRAY() helper
6
7 We are moving toward replacing zero-length arrays with C99 flexible-array
8 members since they are deprecated. Therefore, the new DECLARE_FLEX_ARRAY()
9 helper macro should be used to replace the zero-length array declaration.
10
11 This fixes warnings such as:
12 ./drivers/nvmem/u-boot-env.c:50:9-13: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
13
14 Signed-off-by: Atul Raut <rauji.raut@gmail.com>
15 Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
16 ---
17 drivers/nvmem/u-boot-env.c | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
19
20 --- a/drivers/nvmem/u-boot-env.c
21 +++ b/drivers/nvmem/u-boot-env.c
22 @@ -47,7 +47,7 @@ struct u_boot_env_image_broadcom {
23 __le32 magic;
24 __le32 len;
25 __le32 crc32;
26 - uint8_t data[0];
27 + DECLARE_FLEX_ARRAY(uint8_t, data);
28 } __packed;
29
30 static int u_boot_env_read(void *context, unsigned int offset, void *val,