Re: [PATCH] mm/mmap.c: silence variable 'new_start' set but not used

From: Qian Cai
Date: Wed Jul 24 2019 - 10:11:10 EST


On Wed, 2019-07-24 at 22:07 +0800, YueHaibing wrote:
> 'new_start' is used in is_hugepage_only_range(),
> which do nothing in some arch. gcc will warning:
>
> mm/mmap.c: In function acct_stack_growth:
> mm/mmap.c:2311:16: warning: variable new_start set but not used [-Wunused-but-
> set-variable]

Nope. Convert them to inline instead.

>
> Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
> Signed-off-by: YueHaibing <yuehaibing@xxxxxxxxxx>
> ---
> Âmm/mmap.c | 2 +-
> Â1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mmap.c b/mm/mmap.c
> index e2dbed3..56c2a92 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2308,7 +2308,7 @@ static int acct_stack_growth(struct vm_area_struct *vma,
> Â ÂÂÂÂÂunsigned long size, unsigned long grow)
> Â{
> Â struct mm_struct *mm = vma->vm_mm;
> - unsigned long new_start;
> + unsigned long __maybe_unused new_start;
> Â
> Â /* address space limit tests */
> Â if (!may_expand_vm(mm, vma->vm_flags, grow))