Skip to contentSkip to conversation

bpf: bpftool: Setting error code in do_loader()

PATCH In review Sewon Nam 2 participants 2 messages Mar 11, 2025

Subsystems (2)
lore
Share & tools
lore

Sewon Nam

author
#0 lore raw

PATCH v2 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. To maintain consistency with other locations where bpf_object__open_file() is called, it returns -1 instead.

---
 tools/bpf/bpftool/prog.c | 1 +
 1 file changed, 1 insertion(+)
tools/bpf/bpftool/prog.c +1 -0
index e71be67f1d86..52ffb74ae4e8 100644
@@ -1928,6 +1928,7 @@ static int do_loader(int argc, char **argv)
 
 	obj = bpf_object__open_file(file, &open_opts);
 	if (!obj) {
+		err = -1;
 		p_err("failed to open object file");
 		goto err_close_obj;
 	}

--
2.39.3 (Apple Git-146)

maintainer Tested-by Reviewed-by on v2 1/1
#1 lore raw

2025-03-11 12:12 UTC+0900 ~ Sewon Nam <[email protected]>

Quoted 4 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. To maintain consistency with other locations where bpf_object__open_file() is called, it returns -1 instead.

Nit: Please wrap long lines in the commit description next time you send a patch.

Quoted 2 lines
Quoted 2 lines

Thank you!