Re: [PATCH 3/4] gcov: add gcov profiling infrastructure

From: Li Wei
Date: Thu Feb 26 2009 - 07:09:41 EST


On Thu, 2009-02-26 at 12:46 +0100, Peter Oberparleiter wrote:
> necessary. My proposed fix looks something like this (unless there
> are objections, I'll include this one in the re-post):

I'd prefer a goto. But this looks nice too. Thanks! :)

> ---
> kernel/gcov/fs.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> Index: linux-2.6.29-rc6/kernel/gcov/fs.c
> ===================================================================
> --- linux-2.6.29-rc6.orig/kernel/gcov/fs.c
> +++ linux-2.6.29-rc6/kernel/gcov/fs.c
> @@ -453,15 +453,22 @@ static ssize_t reset_write(struct file *
> size_t len, loff_t *pos)
> {
> struct gcov_node *node;
> - struct gcov_node *r;
> + int restart;
>
> mutex_lock(&node_lock);
> - list_for_each_entry_safe(node, r, &all_head, all) {
> - if (node->info)
> - gcov_info_reset(node->info);
> - else
> - remove_node(node);
> - }
> + do {
> + restart = 0;
> + list_for_each_entry(node, &all_head, all) {
> + if (node->info)
> + gcov_info_reset(node->info);
> + else if (list_empty(&node->children)) {
> + remove_node(node);
> + /* Several nodes may have gone - restart. */
> + restart = 1;
> + break;
> + }
> + }
> + } while (restart);
> mutex_unlock(&node_lock);
>
> return len;
>

--
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/