提交 01081be1 编写于 作者: J José Expósito 提交者: Jakub Kicinski

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/78Signed-off-by: NJosé Expósito <jose.exposito89@gmail.com>
Reviewed-by: NVolodymyr Mytnyk <vmytnyk@marvell.com>
Tested-by: NVolodymyr Mytnyk <vmytnyk@marvell.com>
Reviewed-by: NGustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20211204171349.22776-1-jose.exposito89@gmail.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
上级 5382911f
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册