aboutsummaryrefslogtreecommitdiff
path: root/lib/test_bpf.c
diff options
context:
space:
mode:
authorGravatar Su Hui <suhui@nfschina.com> 2023-05-31 12:32:51 +0800
committerGravatar Daniel Borkmann <daniel@iogearbox.net> 2023-05-31 12:58:38 +0200
commit0d2da4b595d03009db7dfb5ebf01c547b89b0ad8 (patch)
treeff77a2a811a44c72b5cd0df9552809620a098eb4 /lib/test_bpf.c
parentselftests/bpf: Add a test where map key_type_id with decl_tag type (diff)
downloadlinux-0d2da4b595d03009db7dfb5ebf01c547b89b0ad8.tar.gz
linux-0d2da4b595d03009db7dfb5ebf01c547b89b0ad8.tar.bz2
linux-0d2da4b595d03009db7dfb5ebf01c547b89b0ad8.zip
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 <suhui@nfschina.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20230531043251.989312-1-suhui@nfschina.com
Diffstat (limited to 'lib/test_bpf.c')
-rw-r--r--lib/test_bpf.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index ade9ac672adb..fa0833410ac1 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;