Re: [PATCH] mm/vmalloc.c: fix sparse warning

From: Andrew Morton
Date: Thu Apr 23 2009 - 16:25:46 EST


On Fri, 17 Apr 2009 20:55:06 -0400
"H Hartley Sweeten" <hartleys@xxxxxxxxxxxxxxxxxxx> wrote:

> Fix sparse warning in mm/vmalloc.c.
>
> warning: symbol 'tmp' shadows an earlier one
>
> Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
>
> ---
>
> diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> index fab1987..4959a30 100644
> --- a/mm/vmalloc.c
> +++ b/mm/vmalloc.c
> @@ -292,13 +292,13 @@ static void __insert_vmap_area(struct vmap_area
> *va)
> struct rb_node *tmp;
>
> while (*p) {
> - struct vmap_area *tmp;
> + struct vmap_area *tmp_va;
>
> parent = *p;
> - tmp = rb_entry(parent, struct vmap_area, rb_node);
> - if (va->va_start < tmp->va_end)
> + tmp_va = rb_entry(parent, struct vmap_area, rb_node);
> + if (va->va_start < tmp_va->va_end)
> p = &(*p)->rb_left;
> - else if (va->va_end > tmp->va_start)
> + else if (va->va_end > tmp_va->va_start)
> p = &(*p)->rb_right;
> else
> BUG();

It would be sufficient to simply delete the inner definition of `tmp'.

Use of a variable called "tmp" is often bad - it's almost always a
result of plain old laziness and the code can be improved by using a
more meaningful identifier.

But in this case the code is sufficiently short and simple that I guess
we can live with "tmp".

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