Skip to content

Commit 93a83d0

Browse files
kknjhMartin KaFai Lau
authored andcommitted
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 <[email protected]> Signed-off-by: Martin KaFai Lau <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent e12873e commit 93a83d0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/testing/selftests/bpf/test_loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ void run_subtest(struct test_loader *tester,
10881088
link = bpf_map__attach_struct_ops(map);
10891089
if (!link) {
10901090
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);
10921092
goto tobj_cleanup;
10931093
}
10941094
links[links_cnt++] = link;

0 commit comments

Comments
 (0)