Re: [PATCH] mm/memory.c: remove warning from an uninitialized spinlock. was: Re: 2.6.21-rc7-mm2

Andrew Morton
2007-04-29T08:21:04Z

On Sun, 29 Apr 2007 08:50:49 +0200 Borislav Petkov <bbpetkov@yahoo.de> wrote:

>
> Introduce a macro for suppressing gcc from generating a warning about a probable
> unitialized state of a variable.
>
> Signed-off-by: Borislav Petkov <bbpetkov@yahoo.de>
>
> ---
>
> Index: linux-mm/include/linux/compiler.h
> ===================================================================
> --- linux-mm.orig/include/linux/compiler.h
> +++ linux-mm/include/linux/compiler.h
> @@ -109,6 +109,10 @@ extern int do_check_likely(struct likeli
> (typeof(ptr)) (__ptr + (off)); })
> #endif
>
> +#ifndef unitialized_var
> +# define unitialized_var(x) x = x
> +#endif
> +
> #endif /* __KERNEL__ */
>
> #endif /* __ASSEMBLY__ */
> Index: linux-mm/mm/memory.c
> ===================================================================
> --- linux-mm.orig/mm/memory.c
> +++ linux-mm/mm/memory.c
> @@ -1488,7 +1488,7 @@ static int apply_to_pte_range(struct mm_
> pte_t *pte;
> int err;
> struct page *pmd_page;
> - spinlock_t *ptl;
> + spinlock_t *unitialized_var(ptl);
>
> pte = (mm == &init_mm) ?
> pte_alloc_kernel(pmd, addr) :

Ho hum. I guess I'll slide this over to Linus if there's not too much
howling, and unless someone can come up with anything better.

I will, however, fix the spelling to "uninitialized" ;)