From: Suzuki K. Poulose Date: Fri, 31 Aug 2012 07:09:18 +0000 (+0530) Subject: Account the nr_entries in rblist properly X-Git-Tag: firefly_0821_release~3680^2~1401^2~30^2~8 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=03f2f93ae00762eb881424df1c688d034fd341ee;p=firefly-linux-kernel-4.4.55.git Account the nr_entries in rblist properly The nr_entries in rblist is never decremented when an element is deleted. Also, use rblist__remove_node to delete a node in rblist__delete(). This would keep the nr_entries sane. Signed-off-by: Suzuki K. Poulose Acked-by: David S. Ahern Cc: David S. Ahern Link: http://lkml.kernel.org/r/20120831070834.14806.87398.stgit@suzukikp.in.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/rblist.c b/tools/perf/util/rblist.c index 0171fb611004..a16cdd2625ad 100644 --- a/tools/perf/util/rblist.c +++ b/tools/perf/util/rblist.c @@ -44,6 +44,7 @@ int rblist__add_node(struct rblist *rblist, const void *new_entry) void rblist__remove_node(struct rblist *rblist, struct rb_node *rb_node) { rb_erase(rb_node, &rblist->entries); + --rblist->nr_entries; rblist->node_delete(rblist, rb_node); } @@ -87,8 +88,7 @@ void rblist__delete(struct rblist *rblist) while (next) { pos = next; next = rb_next(pos); - rb_erase(pos, &rblist->entries); - rblist->node_delete(rblist, pos); + rblist__remove_node(rblist, pos); } free(rblist); }