Skip to contentSkip to conversation

nvmem: u-boot-env:: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

PATCH Applied Atul Raut 2 participants 2 messages Jul 30, 2023 – Aug 1, 2023

Subsystems (2)
lore
Share & tools
lore

Atul Raut

author
#0 lore raw

PATCH 1/1 nvmem: u-boot-env:: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

We are moving toward replacing zero-length arrays with C99 flexible-array members since they are deprecated. Therefore, the new DECLARE_FLEX_ARRAY() helper macro should be used to replace the zero-length array declaration.

This fixes warnings such as:
./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)

---
 drivers/nvmem/u-boot-env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/u-boot-env.c +1 -1
index ee9fd9989b6e..5f4f53c6c17b 100644
@@ -47,7 +47,7 @@ struct u_boot_env_image_broadcom {
 	__le32 magic;
 	__le32 len;
 	__le32 crc32;
-	uint8_t data[0];
+	DECLARE_FLEX_ARRAY(uint8_t, data);
 } __packed;
 
 static int u_boot_env_read(void *context, unsigned int offset, void *val,
Signature · 6 lines
2.41.0

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw
Quoted 8 lines · Atul Raut

We are moving toward replacing zero-length arrays with C99 flexible-array members since they are deprecated. Therefore, the new DECLARE_FLEX_ARRAY() helper macro should be used to replace the zero-length array declaration.

This fixes warnings such as:
./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)

[...]

Applied, thanks!

[1/1] nvmem: u-boot-env:: Replace zero-length array with DECLARE_FLEX_ARRAY() helper

      commit: 3c74e2b14ff03aa9434a91809ad9d354181f43ca

Best regards,

Signature · 6 lines
Srinivas Kandagatla <[email protected]>

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees