mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 17:11:46 +00:00
tracing/filter: Change count_leafs function to use walk_pred_tree
Changing count_leafs function to use unified predicates tree processing. Signed-off-by: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/1313072754-4620-7-git-send-email-jolsa@redhat.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
parent
f03f597994
commit
c00b060f36
1 changed files with 15 additions and 34 deletions
|
@ -1418,43 +1418,24 @@ static int check_pred_tree(struct event_filter *filter,
|
||||||
check_pred_tree_cb, &data);
|
check_pred_tree_cb, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int count_leafs_cb(enum move_type move, struct filter_pred *pred,
|
||||||
|
int *err, void *data)
|
||||||
|
{
|
||||||
|
int *count = data;
|
||||||
|
|
||||||
|
if ((move == MOVE_DOWN) &&
|
||||||
|
(pred->left == FILTER_PRED_INVALID))
|
||||||
|
(*count)++;
|
||||||
|
|
||||||
|
return WALK_PRED_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
static int count_leafs(struct filter_pred *preds, struct filter_pred *root)
|
static int count_leafs(struct filter_pred *preds, struct filter_pred *root)
|
||||||
{
|
{
|
||||||
struct filter_pred *pred;
|
int count = 0, ret;
|
||||||
enum move_type move = MOVE_DOWN;
|
|
||||||
int count = 0;
|
|
||||||
int done = 0;
|
|
||||||
|
|
||||||
pred = root;
|
|
||||||
|
|
||||||
do {
|
|
||||||
switch (move) {
|
|
||||||
case MOVE_DOWN:
|
|
||||||
if (pred->left != FILTER_PRED_INVALID) {
|
|
||||||
pred = &preds[pred->left];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* A leaf at the root is just a leaf in the tree */
|
|
||||||
if (pred == root)
|
|
||||||
return 1;
|
|
||||||
count++;
|
|
||||||
pred = get_pred_parent(pred, preds,
|
|
||||||
pred->parent, &move);
|
|
||||||
continue;
|
|
||||||
case MOVE_UP_FROM_LEFT:
|
|
||||||
pred = &preds[pred->right];
|
|
||||||
move = MOVE_DOWN;
|
|
||||||
continue;
|
|
||||||
case MOVE_UP_FROM_RIGHT:
|
|
||||||
if (pred == root)
|
|
||||||
break;
|
|
||||||
pred = get_pred_parent(pred, preds,
|
|
||||||
pred->parent, &move);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
done = 1;
|
|
||||||
} while (!done);
|
|
||||||
|
|
||||||
|
ret = walk_pred_tree(preds, root, count_leafs_cb, &count);
|
||||||
|
WARN_ON(ret);
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue