net/macmace: Replace zero-length array with DECLARE_FLEX_ARRAY() helper
Subsystems (2)
PATCH 1/1 net/macmace: Replace zero-length array with DECLARE_FLEX_ARRAY() helper
Since zero-length arrays are deprecated, we are replacing them with C99 flexible-array members. As a result, instead of declaring a zero-length array, use the new DECLARE_FLEX_ARRAY() helper macro.
This fixes warnings such as:
./drivers/net/ethernet/apple/macmace.c:80:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)
--- drivers/net/ethernet/apple/macmace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/apple/macmace.c +1 -1
@@ -77,7 +77,7 @@ struct mace_frame {u8 pad4;u32 pad5;u32 pad6; -u8 data[1 ]; +DECLARE_FLEX_ARRAY (u8, data);/* And frame continues.. */ };
Signature · 1 line
2.34.1
Quoted 18 lines · Atul Raut
Since zero-length arrays are deprecated, we are replacing them with C99 flexible-array members. As a result, instead of declaring a zero-length array, use the new
DECLARE_FLEX_ARRAY()helper macro.This fixes warnings such as:
./drivers/net/ethernet/apple/macmace.c:80:4-8: 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 <[email protected]>--- drivers/net/ethernet/apple/macmace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/apple/macmace.c +0
-0
drivers/net/ethernet/apple/macmace.c struct mace_frame { · line 80
Quoted 5 lines
drivers/net/ethernet/apple/macmace.c +1
-1@@ -77,7 +77,7 @@ struct mace_frame {u8 pad4;u32 pad5;u32 pad6; -u8 data[1 ]; +DECLARE_FLEX_ARRAY (u8, data);
But data[1] is not zero-length array.
Quoted 7 lines
drivers/net/ethernet/apple/macmace.c +0
-0/* And frame continues.. */ };Signature · 1 line
2.34.1
Quoted 14 lines · Leon Romanovsky
Quoted 13 lines · Atul Raut
Since zero-length arrays are deprecated, we are replacing them with C99 flexible-array members. As a result, instead of declaring a zero-length array, use the new
DECLARE_FLEX_ARRAY()helper macro.This fixes warnings such as:
./drivers/net/ethernet/apple/macmace.c:80:4-8: 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 <[email protected]>--- drivers/net/ethernet/apple/macmace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
drivers/net/ethernet/apple/macmace.c struct mace_frame { · line 80
Quoted 10 lines
drivers/net/ethernet/apple/macmace.c +1
-1@@ -77,7 +77,7 @@ struct mace_frame {u8 pad4;u32 pad5;u32 pad6; -u8 data[1 ]; +DECLARE_FLEX_ARRAY (u8, data);But data[1] is not zero-length array.
So, please, if you are certain that data should be a flexible array, send v2 without calling data a zero-length array. Also, with such change, I think driver code could be improved in many places in the same patchset.
Quoted 8 lines
Quoted 7 lines
drivers/net/ethernet/apple/macmace.c +0
-0/* And frame continues.. */ };Signature · 1 line
2.34.1
Jakub Kicinski
maintainerQuoted 8 lines · On Tue, 1 Aug 2023 16:09:37 +0200 Larysa Zaremba wrote:
Quoted 4 lines
drivers/net/ethernet/apple/macmace.c struct mace_frame { · line 80
Quoted 2 lines
drivers/net/ethernet/apple/macmace.c +1
-1-u8 data[1 ]; +DECLARE_FLEX_ARRAY (u8, data);But data[1] is not zero-length array.
So, please, if you are certain that data should be a flexible array, send v2 without calling data a zero-length array. Also, with such change, I think driver code could be improved in many places in the same patchset.
Atul, you should respond to reviewers promptly. These are legit questions.
On closer inspection the patch looks fine so to avoid clogging up the review queue and wasting more time on it I'm just going to apply it.
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sun, 30 Jul 2023 16:14:42 -0700 you wrote:
Since zero-length arrays are deprecated, we are replacing them with C99 flexible-array members. As a result, instead of declaring a zero-length array, use the new
DECLARE_FLEX_ARRAY()helper macro.This fixes warnings such as:
./drivers/net/ethernet/apple/macmace.c:80:4-8: WARNING use flexible-array member instead (https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays)[...]
Here is the summary with links:
- net/macmace: Replace zero-length array with DECLARE_FLEX_ARRAY() helper
https://git.kernel.org/netdev/net-next/c/005c9600003e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html