linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mmap.c: silence variable 'new_start' set but not used
@ 2019-07-24 14:07 YueHaibing
  2019-07-24 14:11 ` Qian Cai
  2019-07-24 14:34 ` Kirill A. Shutemov
  0 siblings, 2 replies; 5+ messages in thread
From: YueHaibing @ 2019-07-24 14:07 UTC (permalink / raw)
  To: akpm, kirill.shutemov, mhocko, vbabka, yang.shi, jannh, walken
  Cc: linux-kernel, linux-mm, YueHaibing

'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]

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 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))
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/mmap.c: silence variable 'new_start' set but not used
  2019-07-24 14:07 [PATCH] mm/mmap.c: silence variable 'new_start' set but not used YueHaibing
@ 2019-07-24 14:11 ` Qian Cai
  2019-07-24 14:17   ` Michal Hocko
  2019-07-24 14:34 ` Kirill A. Shutemov
  1 sibling, 1 reply; 5+ messages in thread
From: Qian Cai @ 2019-07-24 14:11 UTC (permalink / raw)
  To: YueHaibing, akpm, kirill.shutemov, mhocko, vbabka, yang.shi,
	jannh, walken
  Cc: linux-kernel, linux-mm

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@huawei.com>
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  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))


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/mmap.c: silence variable 'new_start' set but not used
  2019-07-24 14:11 ` Qian Cai
@ 2019-07-24 14:17   ` Michal Hocko
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2019-07-24 14:17 UTC (permalink / raw)
  To: Qian Cai
  Cc: YueHaibing, akpm, kirill.shutemov, vbabka, yang.shi, jannh,
	walken, linux-kernel, linux-mm

On Wed 24-07-19 10:11:05, Qian Cai wrote:
> 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.

Agreed. Obfuscating the code is not really something we want.

> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> > ---
> >  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))

-- 
Michal Hocko
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/mmap.c: silence variable 'new_start' set but not used
  2019-07-24 14:07 [PATCH] mm/mmap.c: silence variable 'new_start' set but not used YueHaibing
  2019-07-24 14:11 ` Qian Cai
@ 2019-07-24 14:34 ` Kirill A. Shutemov
  2019-07-25  9:30   ` Yuehaibing
  1 sibling, 1 reply; 5+ messages in thread
From: Kirill A. Shutemov @ 2019-07-24 14:34 UTC (permalink / raw)
  To: YueHaibing
  Cc: akpm, mhocko, vbabka, yang.shi, jannh, walken, linux-kernel, linux-mm

On Wed, Jul 24, 2019 at 02:07:39PM +0000, YueHaibing wrote:
> 'new_start' is used in is_hugepage_only_range(),
> which do nothing in some arch. gcc will warning:

Make is_hugepage_only_range() reference the variable on such archs:

#define is_hugepage_only_range(mm, addr, len)   ((void) addr, 0)

-- 
 Kirill A. Shutemov


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mm/mmap.c: silence variable 'new_start' set but not used
  2019-07-24 14:34 ` Kirill A. Shutemov
@ 2019-07-25  9:30   ` Yuehaibing
  0 siblings, 0 replies; 5+ messages in thread
From: Yuehaibing @ 2019-07-25  9:30 UTC (permalink / raw)
  To: Kirill A. Shutemov
  Cc: akpm, mhocko, vbabka, yang.shi, jannh, walken, linux-kernel, linux-mm

On 2019/7/24 22:34, Kirill A. Shutemov wrote:
> On Wed, Jul 24, 2019 at 02:07:39PM +0000, YueHaibing wrote:
>> 'new_start' is used in is_hugepage_only_range(),
>> which do nothing in some arch. gcc will warning:
> 
> Make is_hugepage_only_range() reference the variable on such archs:
> 
> #define is_hugepage_only_range(mm, addr, len)   ((void) addr, 0)

Thank you for suggestion, I will try this.

> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-25  9:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 14:07 [PATCH] mm/mmap.c: silence variable 'new_start' set but not used YueHaibing
2019-07-24 14:11 ` Qian Cai
2019-07-24 14:17   ` Michal Hocko
2019-07-24 14:34 ` Kirill A. Shutemov
2019-07-25  9:30   ` Yuehaibing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).