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

selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms

When cross-compiling test_verifier for 32-bit platforms, the casting error is shown below:

test_verifier.c:1263:27: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
1263 | info.xlated_prog_insns = (__u64)*buf;
| ^
cc1: all warnings being treated as errors

Fix it by adding zero-extension for it.

Fixes: 933ff53191eb ("selftests/bpf: specify expected instructions in test_verifier tests")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20221108121945.4104644-1-pulehui@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Pu Lehui and committed by
Martin KaFai Lau
0811664d eb86559a

+1 -1
+1 -1
tools/testing/selftests/bpf/test_verifier.c
··· 1260 1260 1261 1261 bzero(&info, sizeof(info)); 1262 1262 info.xlated_prog_len = xlated_prog_len; 1263 - info.xlated_prog_insns = (__u64)*buf; 1263 + info.xlated_prog_insns = (__u64)(unsigned long)*buf; 1264 1264 if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) { 1265 1265 perror("second bpf_obj_get_info_by_fd failed"); 1266 1266 goto out_free_buf;