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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ee2555b6
...@@ -1007,7 +1007,7 @@ struct map *maps__first(struct maps *maps) ...@@ -1007,7 +1007,7 @@ struct map *maps__first(struct maps *maps)
return NULL; 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); struct rb_node *next = rb_next(&map->rb_node);
...@@ -1016,6 +1016,11 @@ struct map *map__next(struct map *map) ...@@ -1016,6 +1016,11 @@ struct map *map__next(struct map *map)
return NULL; return NULL;
} }
struct map *map__next(struct map *map)
{
return map ? __map__next(map) : NULL;
}
struct kmap *__map__kmap(struct map *map) struct kmap *__map__kmap(struct map *map)
{ {
if (!map->dso || !map->dso->kernel) if (!map->dso || !map->dso->kernel)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment