Skip to content

Commit

Permalink
net: prestera: replace zero-length array with flexible-array member
Browse files Browse the repository at this point in the history
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: KSPP/linux#78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
  • Loading branch information
JoseExposito committed Dec 4, 2021
1 parent 7afeac3 commit ece1df0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/ethernet/marvell/prestera/prestera_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ece1df0

Please sign in to comment.