Skip to content

Commit e9c0ae4

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. When bpf_map__attach_struct_ops encounters an error, it uses libbpf_err_ptr(err) to set errno = -err and returns NULL. Therefore, strerror(errno) can be used to 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: Bad file descriptor Signed-off-by: Feng Yang <[email protected]>
1 parent 83124e1 commit e9c0ae4

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: %s\n",
1091+
bpf_map__name(map), strerror(errno));
10921092
goto tobj_cleanup;
10931093
}
10941094
links[links_cnt++] = link;

0 commit comments

Comments
 (0)