perf map: Allow map__next() to receive a NULL arg

Just like free(), return NULL in that case, will simplify the
for_each_entry_safe() iterators.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-pbde2ucn49khnrebclys9pny@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-10-28 11:50:12 -03:00
parent ee2555b612
commit 20419d3a5b

View file

@ -1007,7 +1007,7 @@ struct map *maps__first(struct maps *maps)
return NULL;
}
struct map *map__next(struct map *map)
static struct map *__map__next(struct map *map)
{
struct rb_node *next = rb_next(&map->rb_node);
@ -1016,6 +1016,11 @@ struct map *map__next(struct map *map)
return NULL;
}
struct map *map__next(struct map *map)
{
return map ? __map__next(map) : NULL;
}
struct kmap *__map__kmap(struct map *map)
{
if (!map->dso || !map->dso->kernel)