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>
This commit is contained in:
Arnaldo Carvalho de Melo
2016-06-02 14:21:06 -03:00
parent 009ad5d594
commit 53897a78ca
3 changed files with 27 additions and 35 deletions

View File

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