mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-10 22:54:11 +08:00
af6f12f22b
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct foo { int stuff; void *entry[]; }; size = sizeof(struct foo) + count * sizeof(void *); instance = alloc(size, GFP_KERNEL); Instead of leaving these open-coded and prone to type mistakes, we can now use the new struct_size() helper: instance = alloc(struct_size(instance, entry, count), GFP_KERNEL); Notice that, in this case, variable size is not necessary, hence it is removed. This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> |
||
---|---|---|
.. | ||
abm | ||
bpf | ||
flower | ||
nfpcore | ||
nic | ||
Makefile | ||
nfp_abi.h | ||
nfp_app_nic.c | ||
nfp_app.c | ||
nfp_app.h | ||
nfp_asm.c | ||
nfp_asm.h | ||
nfp_devlink.c | ||
nfp_hwmon.c | ||
nfp_main.c | ||
nfp_main.h | ||
nfp_net_common.c | ||
nfp_net_ctrl.c | ||
nfp_net_ctrl.h | ||
nfp_net_debugdump.c | ||
nfp_net_debugfs.c | ||
nfp_net_ethtool.c | ||
nfp_net_main.c | ||
nfp_net_repr.c | ||
nfp_net_repr.h | ||
nfp_net_sriov.c | ||
nfp_net_sriov.h | ||
nfp_net.h | ||
nfp_netvf_main.c | ||
nfp_port.c | ||
nfp_port.h | ||
nfp_shared_buf.c |