bpf: bpftool: Setting error code in do_loader()
PATCH 1/1 bpf: bpftool: Setting error code in do_loader()
missing error code in do_loader()bpf_object__open_file() failed, but return 0
This means the command's exit status code was successful, so make sure to return the correct error code.
--- tools/bpf/bpftool/prog.c | 1 + 1 file changed, 1 insertion(+)
tools/bpf/bpftool/prog.c +1 -0
@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv) obj =bpf_object__open_file (file, &open_opts);if (!obj) { + err =libbpf_get_error (obj);p_err ("failed to open object file" ); goto err_close_obj; }
Signature · 1 line
2.39.3 (Apple Git-146)
Quentin Monnet
maintainer2025-03-10 14:25 UTC+0900 ~ nswon <[email protected]>
Quoted 7 lines
missing error code in
do_loader()bpf_object__open_file()failed, but return 0
This means the command's exit status code was successful, so make sure to return the correct error code.
Thanks for this!
Others may correct me if I'm wrong, but I think you should sign off with your full name here (although it doesn't strictly have to be a full name, the patch submission docs mention in should be a "known identity" so I'm not sure whether a GitHub handle, for example, is acceptable).
tools/bpf/bpftool/prog.c static int do_loader(int argc, char **argv) · line 1931
Quoted 13 lines
--- tools/bpf/bpftool/prog.c | 1 + 1 file changed, 1 insertion(+)tools/bpf/bpftool/prog.c +1
-0@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv) obj =bpf_object__open_file (file, &open_opts);if (!obj) { + err =libbpf_get_error (obj);
This is the correct way to retrieve the error code, but given that bpftool does nothing with this error code, could we instead simply return -1 to remain consistent with the other locations where we call bpf_object__open_file() in the tool, please?
Thanks,
Quentin
Ngomhla ka-Mso, Mas 10, 2025 ngo-22:28 Quentin Monnet <[email protected]> wabhala:
Quoted 39 lines
2025-03-10 14:25 UTC+0900 ~ nswon <[email protected]>
Quoted 7 lines
missing error code in
do_loader()bpf_object__open_file()failed, but return 0
This means the command's exit status code was successful, so make sure to return the correct error code.Thanks for this!
Others may correct me if I'm wrong, but I think you should sign off with your full name here (although it doesn't strictly have to be a full name, the patch submission docs mention in should be a "known identity" so I'm not sure whether a GitHub handle, for example, is acceptable).
tools/bpf/bpftool/prog.c static int do_loader(int argc, char **argv) · line 1931
Quoted 13 lines
--- tools/bpf/bpftool/prog.c | 1 + 1 file changed, 1 insertion(+)tools/bpf/bpftool/prog.c +1
-0@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv) obj =bpf_object__open_file (file, &open_opts);if (!obj) { + err =libbpf_get_error (obj);This is the correct way to retrieve the error code, but given that bpftool does nothing with this error code, could we instead simply return -1 to remain consistent with the other locations where we call
bpf_object__open_file()in the tool, please?
Quoted 2 lines
Thanks,
Quentin
Thanks for the review!
I'll submit a v2 patch soon with the signature renamed :)