lkml.org 
[lkml]   [2019]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] mm/hmm: fix unused variable warnings
From
Date


On 03/05/2019 01:30 AM, Arnd Bergmann wrote:
> When CONFIG_HUGETLB_PAGE is disabled, the only use of the variable 'h'
> is compiled out, and the compiler thinks it is unnecessary:
>
> mm/hmm.c: In function 'hmm_range_snapshot':
> mm/hmm.c:1015:19: error: unused variable 'h' [-Werror=unused-variable]
> struct hstate *h = hstate_vma(vma);

After doing some Kconfig hacks like (ARCH_WANT_GENERAL_HUGETLB = n) on an
X86 system I got (HUGETLB_PAGE = n and HMM = y) config. But was unable to
hit the build error. Helper is_vm_hugetlb_page() seems to always return
false when HUGETLB_PAGE = n. Would not the compiler remove the entire code
block including the declaration for 'h' ?

#ifdef CONFIG_HUGETLB_PAGE
#include <linux/mm.h>
static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma)
{
return !!(vma->vm_flags & VM_HUGETLB);
}
#else
static inline bool is_vm_hugetlb_page(struct vm_area_struct *vma)
{
return false;
}
#endif

\
 
 \ /
  Last update: 2019-03-05 13:18    [W:1.764 / U:0.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site