Re: [PATCH] tools/bpftool: Fix error return code in do_skeleton()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/15/20 5:13 AM, YueHaibing wrote:
The error return code should be PTR_ERR(obj) other than
PTR_ERR(NULL).

Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside skeleton")
Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
---
  tools/bpf/bpftool/gen.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c
index 10de76b296ba..35f62273cdbd 100644
--- a/tools/bpf/bpftool/gen.c
+++ b/tools/bpf/bpftool/gen.c
@@ -305,8 +305,9 @@ static int do_skeleton(int argc, char **argv)
  	opts.object_name = obj_name;
  	obj = bpf_object__open_mem(obj_data, file_sz, &opts);
  	if (IS_ERR(obj)) {
+		err = PTR_ERR(obj);
+		p_err("failed to open BPF object file: %ld", err);
  		obj = NULL;
-		p_err("failed to open BPF object file: %ld", PTR_ERR(obj));
  		goto out;

Instead of just the error number, could we dump something useful to the user here
via libbpf_strerror() given you touch this line? Also, I think the convention in
do_skeleton() is to just return {0,-1} given this is propagated as return code
for bpftool.

  	}




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux