diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-02 13:21:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-06 17:18:55 -0400 |
commit | 53897a78ca6d4bd64e8c17d76cfec65d237f9447 (patch) | |
tree | 10cd769f2e67012fde24dda86ec720416d599d34 /tools/lib | |
parent | 009ad5d5945697a887f0c1b2d581503d92dcde6f (diff) |
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 <wangnan0@huawei.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/n/tip-mer00xqkiho0ymg66b5i9luw@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 8 | ||||
-rw-r--r-- | tools/lib/bpf/libbpf.h | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 4dc617befd13..215be67f038b 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1319,13 +1319,9 @@ int bpf_map__get_fd(struct bpf_map *map) | |||
1319 | return map->fd; | 1319 | return map->fd; |
1320 | } | 1320 | } |
1321 | 1321 | ||
1322 | int bpf_map__get_def(struct bpf_map *map, struct bpf_map_def *pdef) | 1322 | const struct bpf_map_def *bpf_map__def(struct bpf_map *map) |
1323 | { | 1323 | { |
1324 | if (!map || !pdef) | 1324 | return map ? &map->def : ERR_PTR(-EINVAL); |
1325 | return -EINVAL; | ||
1326 | |||
1327 | *pdef = map->def; | ||
1328 | return 0; | ||
1329 | } | 1325 | } |
1330 | 1326 | ||
1331 | const char *bpf_map__name(struct bpf_map *map) | 1327 | const char *bpf_map__name(struct bpf_map *map) |
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index f8fbba4ccef3..bad5bac58db4 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h | |||
@@ -181,7 +181,7 @@ bpf_map__next(struct bpf_map *map, struct bpf_object *obj); | |||
181 | (pos) = bpf_map__next((pos), (obj))) | 181 | (pos) = bpf_map__next((pos), (obj))) |
182 | 182 | ||
183 | int bpf_map__get_fd(struct bpf_map *map); | 183 | int bpf_map__get_fd(struct bpf_map *map); |
184 | int bpf_map__get_def(struct bpf_map *map, struct bpf_map_def *pdef); | 184 | const struct bpf_map_def *bpf_map__def(struct bpf_map *map); |
185 | const char *bpf_map__name(struct bpf_map *map); | 185 | const char *bpf_map__name(struct bpf_map *map); |
186 | 186 | ||
187 | typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *); | 187 | typedef void (*bpf_map_clear_priv_t)(struct bpf_map *, void *); |