tools lib bpf: Use IS_ERR() reporting macros with bpf_map__get_def()
Subsystems (3)
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 53897a78ca6d4bd64e8c17d76cfec65d237f9447 Gitweb: http://git.kernel.org/tip/53897a78ca6d4bd64e8c17d76cfec65d237f9447 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 2 Jun 2016 14:21:06 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 6 Jun 2016 18:18:55 -0300
tools lib bpf: Use IS_ERR() reporting macros with bpf_map__get_def()
And for consistency, rename it to bpf_map__def(), leaving "get" for reference counting.
Also make it return a const pointer, as suggested by Wang.
Acked-by Wang Nan <[email protected]>
Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Milian Wolff <[email protected]>
Cc Namhyung Kim <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/lib/bpf/libbpf.c | 8 ++----- tools/lib/bpf/libbpf.h | 2 +- tools/perf/util/bpf-loader.c | 52 ++++++++++++++++++++------------------------ 3 files changed, 27 insertions(+), 35 deletions(-)
tools/lib/bpf/libbpf.c +2 -6
@@ -1319,13 +1319,9 @@ int bpf_map__get_fd(struct bpf_map *map)return map->fd; } -int bpf_map__get_def (struct bpf_map *map,struct bpf_map_def *pdef) +const struct bpf_map_def *bpf_map__def (struct bpf_map *map) { -if (!map || !pdef) -return -EINVAL ; - - *pdef = map->def; -return 0 ; +return map ? &map->def :ERR_PTR (-EINVAL ); }const char *bpf_map__name (struct bpf_map *map)
tools/lib/bpf/libbpf.h +1 -1
@@ -181,7 +181,7 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj); (pos) = bpf_map__next((pos), (obj)))int bpf_map__get_fd (struct bpf_map *map); -int bpf_map__get_def (struct bpf_map *map,struct bpf_map_def *pdef); +const struct bpf_map_def *bpf_map__def (struct bpf_map *map);const char *bpf_map__name (struct bpf_map *map);typedef void (*bpf_map_clear_priv_t )(struct bpf_map *,void *);
tools/perf/util/bpf-loader.c +24 -28
164 lines not on this page · raw message