Skip to contentSkip to conversation

nvmem: u-boot-env: replace zero-length array with flexible-array member

PATCH In review Gustavo A. R. Silva 3 participants 4 messages Jan 10, 2023 – Jan 25, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvmem: u-boot-env: replace zero-length array with flexible-array member

Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct u_boot_env_image_broadcom with flex-array member.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2].

---
 drivers/nvmem/u-boot-env.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/u-boot-env.c +1 -1
index 29b1d87a3c51..6b48637d9e64 100644
@@ -45,7 +45,7 @@ struct u_boot_env_image_broadcom {
 	__le32 magic;
 	__le32 len;
 	__le32 crc32;
-	uint8_t data[0];
+	uint8_t data[];
 } __packed;
 
 static int u_boot_env_read(void *context, unsigned int offset, void *val,
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct u_boot_env_image_broadcom with flex-array member.

Quoted 8 lines

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2].

Signature · 1 line
Kees Cook
maintainer
#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 8 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct u_boot_env_image_broadcom with flex-array member.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2].

I also handled this issue in my
[PATCH V2 4/6] nvmem: u-boot-env: convert to layout driver
https://lore.kernel.org/linux-arm-kernel/[email protected]/

#3 lore raw
Quoted 6 lines · Rafał Miłecki
Quoted 5 lines · Gustavo A. R. Silva

Zero-length arrays are deprecated[1] and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration in struct u_boot_env_image_broadcom with flex-array member.

Quoted 7 lines
Quoted 3 lines

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [2].

I also handled this issue in my
[PATCH V2 4/6] nvmem: u-boot-env: convert to layout driver
https://lore.kernel.org/linux-arm-kernel/[email protected]/

Ah-ha, thanks! Looks good. :)

Signature · 1 line
Kees Cook