net: prestera: replace zero-length array with flexible-array member
Subsystems (3)
PATCH 1/1 net: prestera: replace zero-length array with flexible-array member
One-element and zero-length arrays are deprecated and should be replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
Replace zero-length array with flexible-array member and make use of the struct_size() helper.
--- drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/prestera/prestera_hw.c +2 -2
@@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {__le32 offset;__le32 num_counters;__le32 done; -struct prestera_msg_counter_stats stats[0 ]; +struct prestera_msg_counter_stats stats[]; };struct prestera_msg_span_req {
@@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx, .block_id = __cpu_to_le32(idx), .num_counters = __cpu_to_le32(*len), }; -size_t size =sizeof (*resp) +sizeof (*resp->stats) * (*len); +size_t size =struct_size (resp, stats, *len);int err, i; resp =kmalloc (size,GFP_KERNEL );
Signature · 1 line
2.25.1
Quoted 39 lines
Subject: [PATCH] net: prestera: replace zero-length array with flexible-array member
One-element and zero-length arrays are deprecated and should be replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arraysReplace zero-length array with flexible-array member and make use of the
struct_size()helper.Signed-off-by Jose Exposito <[email protected]>--- drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/marvell/prestera/prestera_hw.c +2
-2@@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {__le32 offset;__le32 num_counters;__le32 done; -struct prestera_msg_counter_stats stats[0 ]; +struct prestera_msg_counter_stats stats[]; };struct prestera_msg_span_req {@@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx, .block_id = __cpu_to_le32(idx), .num_counters = __cpu_to_le32(*len), }; -size_t size =sizeof (*resp) +sizeof (*resp->stats) * (*len); +size_t size =struct_size (resp, stats, *len);int err, i; resp =kmalloc (size,GFP_KERNEL );Signature · 1 line
2.25.1
Thanks.
Quoted 9 lines · José Expósito
One-element and zero-length arrays are deprecated and should be replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arraysReplace zero-length array with flexible-array member and make use of the
struct_size()helper.Signed-off-by José Expósito <[email protected]>
Thanks
--
Gustavo
Quoted 29 lines
--- drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/ethernet/marvell/prestera/prestera_hw.c +2
-2@@ -443,7 +443,7 @@ struct prestera_msg_counter_resp {__le32 offset;__le32 num_counters;__le32 done; -struct prestera_msg_counter_stats stats[0 ]; +struct prestera_msg_counter_stats stats[]; };struct prestera_msg_span_req {@@ -1900,7 +1900,7 @@ int prestera_hw_counters_get(struct prestera_switch *sw, u32 idx, .block_id = __cpu_to_le32(idx), .num_counters = __cpu_to_le32(*len), }; -size_t size =sizeof (*resp) +sizeof (*resp->stats) * (*len); +size_t size =struct_size (resp, stats, *len);int err, i; resp =kmalloc (size,GFP_KERNEL );Signature · 1 line
2.25.1
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sat, 4 Dec 2021 18:13:49 +0100 you wrote:
One-element and zero-length arrays are deprecated and should be replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arraysReplace zero-length array with flexible-array member and make use of the
struct_size()helper.[...]
Here is the summary with links:
- net: prestera: replace zero-length array with flexible-array member
https://git.kernel.org/netdev/net-next/c/01081be1ea8c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html