Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: openvswitch: Use struct_size()

Use struct_size() instead of hand writing it.
This is less verbose and more robust.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/e5122b4ff878cbf3ed72653a395ad5c4da04dc1e.1697264974.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Christophe JAILLET and committed by
Paolo Abeni
df3bf90f 53c6b86c

+2 -5
+2 -5
net/openvswitch/flow_table.c
··· 220 220 struct mask_array *new; 221 221 222 222 size = max(MASK_ARRAY_SIZE_MIN, size); 223 - new = kzalloc(sizeof(struct mask_array) + 224 - sizeof(struct sw_flow_mask *) * size + 223 + new = kzalloc(struct_size(new, masks, size) + 225 224 sizeof(u64) * size, GFP_KERNEL); 226 225 if (!new) 227 226 return NULL; 228 227 229 228 new->masks_usage_zero_cntr = (u64 *)((u8 *)new + 230 - sizeof(struct mask_array) + 231 - sizeof(struct sw_flow_mask *) * 232 - size); 229 + struct_size(new, masks, size)); 233 230 234 231 new->masks_usage_stats = __alloc_percpu(sizeof(struct mask_array_stats) + 235 232 sizeof(u64) * size,