[PATCH 2/2] perf tools: Use rb_entry_safe on first / next symbol lookup

From: Alex Snast
Date: Sat Sep 19 2015 - 09:04:23 EST


Signed-off-by: Alex Snast <asnast@xxxxxxxxx>
---
tools/perf/util/symbol.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 8b3608c..5728121 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -344,20 +344,14 @@ static struct symbol *symbols__first(struct rb_root *symbols)
{
struct rb_node *n = rb_first(symbols);

- if (n)
- return rb_entry(n, struct symbol, rb_node);
-
- return NULL;
+ return rb_entry_safe(n, struct symbol, rb_node);
}

static struct symbol *symbols__next(struct symbol *sym)
{
struct rb_node *n = rb_next(&sym->rb_node);

- if (n)
- return rb_entry(n, struct symbol, rb_node);
-
- return NULL;
+ return rb_entry_safe(n, struct symbol, rb_node);
}

struct symbol_name_rb_node {
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/