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

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

authored by

Su Hui and committed by
Daniel Borkmann
0d2da4b5 e38096d9

+1 -2
+1 -2
lib/test_bpf.c
··· 15056 15056 int which, err; 15057 15057 15058 15058 /* Allocate the table of programs to be used for tall calls */ 15059 - progs = kzalloc(sizeof(*progs) + (ntests + 1) * sizeof(progs->ptrs[0]), 15060 - GFP_KERNEL); 15059 + progs = kzalloc(struct_size(progs, ptrs, ntests + 1), GFP_KERNEL); 15061 15060 if (!progs) 15062 15061 goto out_nomem; 15063 15062