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

Configure Feed

Select the types of activity you want to include in your feed.

selftests/bpf: Fix the issue where the error code is 0

The error message printed here only uses the previous err value,
which results in it being printed as 0.
When bpf_map__attach_struct_ops encounters an error,
it uses libbpf_err_ptr(err) to set errno = -err and returns NULL.
Therefore, Using -errno can fix this issue.

Fix before:
run_subtest:FAIL:1019 bpf_map__attach_struct_ops failed for map pro_epilogue: err=0

Fix after:
run_subtest:FAIL:1019 bpf_map__attach_struct_ops failed for map pro_epilogue: err=-9

Signed-off-by: Feng Yang <yangfeng@kylinos.cn>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20250908060810.1054341-1-yangfeng59949@163.com

authored by

Feng Yang and committed by
Martin KaFai Lau
93a83d04 e12873ee

+1 -1
+1 -1
tools/testing/selftests/bpf/test_loader.c
··· 1088 1088 link = bpf_map__attach_struct_ops(map); 1089 1089 if (!link) { 1090 1090 PRINT_FAIL("bpf_map__attach_struct_ops failed for map %s: err=%d\n", 1091 - bpf_map__name(map), err); 1091 + bpf_map__name(map), -errno); 1092 1092 goto tobj_cleanup; 1093 1093 } 1094 1094 links[links_cnt++] = link;