From patchwork Tue Nov 3 10:44:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 55924 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp1767882lbr; Tue, 3 Nov 2015 03:01:15 -0800 (PST) X-Received: by 10.68.137.234 with SMTP id ql10mr32888365pbb.33.1446548473954; Tue, 03 Nov 2015 03:01:13 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ku5si41482900pbc.25.2015.11.03.03.01.13; Tue, 03 Nov 2015 03:01:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753477AbbKCLBI (ORCPT + 28 others); Tue, 3 Nov 2015 06:01:08 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:2491 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753218AbbKCLBE (ORCPT ); Tue, 3 Nov 2015 06:01:04 -0500 Received: from 172.24.1.50 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.50]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BQI59266; Tue, 03 Nov 2015 18:45:02 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Tue, 3 Nov 2015 18:44:54 +0800 From: Wang Nan To: CC: , , , Wang Nan , Arnaldo Carvalho de Melo Subject: [PATCH 3/5] perf tools: Parsing libbpf return value using err.h Date: Tue, 3 Nov 2015 10:44:44 +0000 Message-ID: <1446547486-229499-4-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1446547486-229499-1-git-send-email-wangnan0@huawei.com> References: <1446547486-229499-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.563893E6.00FF, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d4217ee18e25e4c9804dd5f7154a352e Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Cc: Arnaldo Carvalho de Melo --- 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/ 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);