Skip to contentSkip to conversation

mtd: rawnand: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper

PATCH In review Atul Raut 2 participants 2 messages Jul 31, 2023

Subsystems (4)
lore
Share & tools
lore

Atul Raut

author
#0 lore raw

PATCH 1/1 mtd: rawnand: Replace zero-length arrays with DECLARE_FLEX_ARRAY() helper

Zero-length arrays are deprecated, and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations alone in structs with the new DECLARE_FLEX_ARRAY() helper macro.

This fixes warnings such as:
./drivers/mtd/nand/raw/tegra_nand.c:189:5-7: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)

---
 drivers/mtd/nand/raw/tegra_nand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/tegra_nand.c +1 -1
index eb0b9d16e8da..45e802b63270 100644
@@ -186,7 +186,7 @@ struct tegra_nand_chip {
 	u32 config;
 	u32 config_ecc;
 	u32 bch_config;
-	int cs[1];
+	DECLARE_FLEX_ARRAY(int, cs);
 };
 
 static inline struct tegra_nand_controller *
Signature · 6 lines
2.34.1

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

Zero-length arrays are deprecated, and we are moving towards adopting C99 flexible-array members, instead. So, replace zero-length arrays declarations alone in structs with the new DECLARE_FLEX_ARRAY() helper macro.

But again, you are not modifying a 0 length array, so why say this?

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