Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933303AbbGGTjw (ORCPT ); Tue, 7 Jul 2015 15:39:52 -0400 Received: from mail.kernel.org ([198.145.29.136]:46160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933211AbbGGTju (ORCPT ); Tue, 7 Jul 2015 15:39:50 -0400 Date: Tue, 7 Jul 2015 16:39:42 -0300 From: Arnaldo Carvalho de Melo To: Wang Nan Cc: ast@plumgrid.com, brendan.d.gregg@gmail.com, daniel@iogearbox.net, namhyung@kernel.org, masami.hiramatsu.pt@hitachi.com, paulus@samba.org, a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org, dsahern@gmail.com, linux-kernel@vger.kernel.org, lizefan@huawei.com, hekuang@huawei.com, xiakaixu@huawei.com, pi3orama@163.com Subject: Re: [RFC PATCH v10 21/50] bpf tools: Introduce accessors for struct bpf_object Message-ID: <20150707193942.GB3135@kernel.org> References: <1435716878-189507-1-git-send-email-wangnan0@huawei.com> <1435716878-189507-22-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1435716878-189507-22-git-send-email-wangnan0@huawei.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1869 Lines: 62 Em Wed, Jul 01, 2015 at 02:14:09AM +0000, Wang Nan escreveu: > This patch add an accessor which allows caller to get count of programs > in an object file. > > Signed-off-by: Wang Nan > Acked-by: Alexei Starovoitov > --- > tools/lib/bpf/libbpf.c | 9 +++++++++ > tools/lib/bpf/libbpf.h | 3 +++ > 2 files changed, 12 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index e4c5f07..1c210fb 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -936,6 +936,15 @@ void bpf_object__close(struct bpf_object *obj) > free(obj); > } > > +int bpf_object__get_prog_cnt(struct bpf_object *obj, size_t *pcnt) > +{ > + if (!obj || !pcnt) > + return -EINVAL; > + > + *pcnt = obj->nr_programs; > + return 0; > +} > + Ditto, what is wrong with: int bpf_object__nr_programs(struct bpf_object *obj) { return obj ? obj->nr_programs : -EINVAL; } - Arnaldo > struct bpf_program * > bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) > { > diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h > index 9e0e102..a20ae2e 100644 > --- a/tools/lib/bpf/libbpf.h > +++ b/tools/lib/bpf/libbpf.h > @@ -35,6 +35,9 @@ void bpf_object__close(struct bpf_object *object); > int bpf_object__load(struct bpf_object *obj); > int bpf_object__unload(struct bpf_object *obj); > > +/* Accessors of bpf_object */ > +int bpf_object__get_prog_cnt(struct bpf_object *obj, size_t *pcnt); > + > /* Accessors of bpf_program. */ > struct bpf_program; > struct bpf_program *bpf_program__next(struct bpf_program *prog, > -- > 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/