mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: <acme@kernel.org>
Cc: <lizefan@huawei.com>, <pi3orama@163.com>,
	<linux-kernel@vger.kernel.org>, Wang Nan <wangnan0@huawei.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 3/5] perf tools: Parsing libbpf return value using err.h
Date: Tue, 3 Nov 2015 10:44:44 +0000	[thread overview]
Message-ID: <1446547486-229499-4-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1446547486-229499-1-git-send-email-wangnan0@huawei.com>

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(-)

diff --git a/tools/perf/tests/llvm.c b/tools/perf/tests/llvm.c
index 512d362..38e0d9a 100644
--- a/tools/perf/tests/llvm.c
+++ b/tools/perf/tests/llvm.c
@@ -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;
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 0c5d174..dd6fa27 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -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);
-- 
1.8.3.4


  parent reply	other threads:[~2015-11-03 11:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-03 10:44 [PATCH 0/5] perf bpf: Improve error code delivering and output Wang Nan
2015-11-03 10:44 ` [PATCH 1/5] perf test: Keep test result clean if '-v' not set Wang Nan
2015-11-03 11:19   ` Namhyung Kim
2015-11-08  7:27   ` [tip:perf/urgent] " tip-bot for Wang Nan
2015-11-03 10:44 ` [PATCH 2/5] perf tools: Mute libbpf when " Wang Nan
2015-11-03 10:49   ` Wangnan (F)
2015-11-08  7:27   ` [tip:perf/urgent] perf bpf: " tip-bot for Wang Nan
2015-11-03 10:44 ` Wang Nan [this message]
2015-11-03 15:17   ` [PATCH 3/5] perf tools: Parsing libbpf return value using err.h Arnaldo Carvalho de Melo
2015-11-03 15:20     ` Arnaldo Carvalho de Melo
2015-11-03 10:44 ` [PATCH 4/5] bpf tools: Improve libbpf error reporting Wang Nan
2015-11-03 10:44 ` [PATCH 5/5] perf tools: Improve BPF related error messages output Wang Nan
2015-11-03 15:43 ` [PATCH 0/5] perf bpf: Improve error code delivering and output Arnaldo Carvalho de Melo
2015-11-04  1:43   ` Wangnan (F)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446547486-229499-4-git-send-email-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=pi3orama@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome