Skip to content

Commit aef0903

Browse files
kknjhKernel Patches Daemon
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. Fix this issue by using libbpf_get_error to retrieve the error. 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]>
1 parent 4e70ac0 commit aef0903

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/bpf/test_loader.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,8 @@ void run_subtest(struct test_loader *tester,
10871087
}
10881088
link = bpf_map__attach_struct_ops(map);
10891089
if (!link) {
1090-
PRINT_FAIL("bpf_map__attach_struct_ops failed for map %s: err=%d\n",
1091-
bpf_map__name(map), err);
1090+
PRINT_FAIL("bpf_map__attach_struct_ops failed for map %s: err=%ld\n",
1091+
bpf_map__name(map), libbpf_get_error(link));
10921092
goto tobj_cleanup;
10931093
}
10941094
links[links_cnt++] = link;

0 commit comments

Comments
 (0)