From: Su Hui Date: Wed, 31 May 2023 04:32:51 +0000 (+0800) Subject: bpf/tests: Use struct_size() X-Git-Tag: v6.6.7~2536^2~23^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d2da4b595d03009db7dfb5ebf01c547b89b0ad8;p=platform%2Fkernel%2Flinux-starfive.git bpf/tests: Use struct_size() Use struct_size() instead of hand writing it. This is less verbose and more informative. Signed-off-by: Su Hui Signed-off-by: Daniel Borkmann Acked-by: Yonghong Song Link: https://lore.kernel.org/bpf/20230531043251.989312-1-suhui@nfschina.com --- diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ade9ac6..fa08334 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -15056,8 +15056,7 @@ static __init int prepare_tail_call_tests(struct bpf_array **pprogs) int which, err; /* Allocate the table of programs to be used for tall calls */ - progs = kzalloc(sizeof(*progs) + (ntests + 1) * sizeof(progs->ptrs[0]), - GFP_KERNEL); + progs = kzalloc(struct_size(progs, ptrs, ntests + 1), GFP_KERNEL); if (!progs) goto out_nomem;