Skip to contentSkip to conversation

perf tools: Allow passing NULL to intlist__find

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Jan 25, 2013 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  5a3d04d6dc9050b4b4562f5c66aea23f0aa1c003
Gitweb:     http://git.kernel.org/tip/5a3d04d6dc9050b4b4562f5c66aea23f0aa1c003
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 24 Jan 2013 16:10:42 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 Jan 2013 16:40:53 -0300

perf tools: Allow passing NULL to intlist__find

So that we can work with optional parameters that may not set up an intlist.

Cc David Ahern <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Stephane Eranian <[email protected]>
---
 tools/perf/util/intlist.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/intlist.c +7 -2
index 9d07400..cbf0c32 100644
@@ -59,9 +59,14 @@ void intlist__remove(struct intlist *ilist, struct int_node *node)
 
 struct int_node *intlist__find(struct intlist *ilist, int i)
 {
-	struct int_node *node = NULL;
-	struct rb_node *rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
+	struct int_node *node;
+	struct rb_node *rb_node;
+
+	if (ilist == NULL)
+		return NULL;
 
+	node = NULL;
+	rb_node = rblist__find(&ilist->rblist, (void *)((long)i));
 	if (rb_node)
 		node = container_of(rb_node, struct int_node, rb_node);