Skip to contentSkip to conversation

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

tip: perf/core tip-bot2 for Arnaldo Carvalho de Melo 1 participant 1 message Nov 12, 2019 1 message not in the archive perf events

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

tip-bot2 for Arnaldo Carvalho de Melo

author merge bot Applied
#1 lore raw

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     20419d3a5bc0a278ed7e2ee54943674004411933
Gitweb:        https://git.kernel.org/tip/20419d3a5bc0a278ed7e2ee54943674004411933
Author:        Arnaldo Carvalho de Melo <[email protected]>
AuthorDate:    Mon, 28 Oct 2019 11:50:12 -03:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Wed, 06 Nov 2019 15:43:06 -03:00

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.

---
 tools/perf/util/map.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/map.c +6 -1
index c9ba495..86d8d18 100644
@@ -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)