]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix casting error when cross-compiling test_verifier for 32-bit platforms
authorPu Lehui <pulehui@huawei.com>
Tue, 8 Nov 2022 12:19:45 +0000 (20:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Nov 2022 08:27:30 +0000 (09:27 +0100)
[ Upstream commit 0811664da064c6d7ca64c02f5579f758a007e52d ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/bpf/test_verifier.c

index f9d553fbf68a3f451afe448494c4e10a013f4db3..ce97a926269897c036594bcde617e12a2600b319 100644 (file)
@@ -1260,7 +1260,7 @@ static int get_xlated_program(int fd_prog, struct bpf_insn **buf, int *cnt)
 
        bzero(&info, sizeof(info));
        info.xlated_prog_len = xlated_prog_len;
-       info.xlated_prog_insns = (__u64)*buf;
+       info.xlated_prog_insns = (__u64)(unsigned long)*buf;
        if (bpf_obj_get_info_by_fd(fd_prog, &info, &info_len)) {
                perror("second bpf_obj_get_info_by_fd failed");
                goto out_free_buf;