@@ -27,7 +27,7 @@ static int test__bpf_parsing(void *obj_buf, size_t obj_buf_sz)
struct bpf_object *obj;
obj = bpf_object__open_buffer(obj_buf, obj_buf_sz, NULL);
- if (!obj)
+ if (IS_ERR(obj) || !obj)
return -1;
bpf_object__close(obj);
return 0;
@@ -59,9 +59,9 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
} else
obj = bpf_object__open(filename);
- if (!obj) {
+ if (IS_ERR(obj) || !obj) {
pr_debug("bpf: failed to load %s\n", filename);
- return ERR_PTR(-EINVAL);
+ return !obj ? ERR_PTR(-EINVAL) : obj;
}
return obj;
@@ -96,9 +96,9 @@ config_bpf_program(struct bpf_program *prog)
int err;
config_str = bpf_program__title(prog, false);
- if (!config_str) {
+ if (IS_ERR(config_str) || !config_str) {
pr_debug("bpf: unable to get title for program\n");
- return -EINVAL;
+ return !config_str ? -EINVAL : PTR_ERR(config_str);
}
priv = calloc(sizeof(*priv), 1);
In following patches libbpf would encode error code using return pointer instead of returnning a NULL pointer to indicate error. This patch makes a preperation to enable perf correctly receive error code from libbpf. Signed-off-by: Wang Nan <wangnan0@huawei.com> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> --- tools/perf/tests/llvm.c | 2 +- tools/perf/util/bpf-loader.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/