Skip to content

Commit

Permalink
net: openvswitch: Use struct_size()
Browse files Browse the repository at this point in the history
Use struct_size() instead of hand writing it.
This is less verbose and more informative.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Link: https://lore.kernel.org/r/e7746fbbd62371d286081d5266e88bbe8d3fe9f0.1683388991.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Christophe JAILLET authored and Jakub Kicinski committed May 18, 2023
1 parent b1cf7a5 commit b50a8b0
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/openvswitch/meter.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ static struct dp_meter_instance *dp_meter_instance_alloc(const u32 size)
{
struct dp_meter_instance *ti;

ti = kvzalloc(sizeof(*ti) +
sizeof(struct dp_meter *) * size,
GFP_KERNEL);
ti = kvzalloc(struct_size(ti, dp_meters, size), GFP_KERNEL);
if (!ti)
return NULL;

Expand Down

0 comments on commit b50a8b0

Please sign in to comment.