diff options
author | José Expósito <jose.exposito89@gmail.com> | 2021-12-04 18:13:49 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-12-06 16:29:27 -0800 |
commit | 01081be1ea8cc123c96256ff0c975643cd862609 (patch) | |
tree | 5d473d4b5b1aa3883fbe4f5cbb38f8f1685e7f04 /drivers/net/ethernet/marvell/prestera | |
parent | 5382911f5d67a5a13815fb6958265b4a11ff7cfd (diff) | |
download | linux-stable-01081be1ea8cc123c96256ff0c975643cd862609.tar.gz linux-stable-01081be1ea8cc123c96256ff0c975643cd862609.tar.bz2 linux-stable-01081be1ea8cc123c96256ff0c975643cd862609.zip |
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.
Link: https://github.com/KSPP/linux/issues/78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
Tested-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20211204171349.22776-1-jose.exposito89@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/marvell/prestera')
-rw-r--r-- | drivers/net/ethernet/marvell/prestera/prestera_hw.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_hw.c b/drivers/net/ethernet/marvell/prestera/prestera_hw.c index 92cb5e9099c6..6282c9822e2b 100644 --- a/drivers/net/ethernet/marvell/prestera/prestera_hw.c +++ b/drivers/net/ethernet/marvell/prestera/prestera_hw.c @@ -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); |