linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/hmm: fix unused variable warnings
@ 2019-03-04 20:00 Arnd Bergmann
  2019-03-05 12:18 ` Anshuman Khandual
  2019-03-05 23:51 ` John Hubbard
  0 siblings, 2 replies; 6+ messages in thread
From: Arnd Bergmann @ 2019-03-04 20:00 UTC (permalink / raw)
  To: Jérôme Glisse
  Cc: Arnd Bergmann, Andrew Morton, Ralph Campbell, Stephen Rothwell,
	John Hubbard, Dan Williams, linux-mm, linux-kernel

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);

Rephrase the code to avoid the temporary variable instead, so the
compiler stops warning.

Fixes: 5409a90d4212 ("mm/hmm: support hugetlbfs (snapshotting, faulting and DMA mapping)")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 mm/hmm.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 3c9781037918..c4beb1628cad 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -1012,9 +1012,8 @@ long hmm_range_snapshot(struct hmm_range *range)
 			return -EFAULT;
 
 		if (is_vm_hugetlb_page(vma)) {
-			struct hstate *h = hstate_vma(vma);
-
-			if (huge_page_shift(h) != range->page_shift &&
+			if (range->page_shift !=
+				huge_page_shift(hstate_vma(vma)) &&
 			    range->page_shift != PAGE_SHIFT)
 				return -EINVAL;
 		} else {
@@ -1115,9 +1114,8 @@ long hmm_range_fault(struct hmm_range *range, bool block)
 			return -EFAULT;
 
 		if (is_vm_hugetlb_page(vma)) {
-			struct hstate *h = hstate_vma(vma);
-
-			if (huge_page_shift(h) != range->page_shift &&
+			if (range->page_shift !=
+				huge_page_shift(hstate_vma(vma)) &&
 			    range->page_shift != PAGE_SHIFT)
 				return -EINVAL;
 		} else {
-- 
2.20.0


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

end of thread, other threads:[~2019-03-06 18:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 20:00 [PATCH] mm/hmm: fix unused variable warnings Arnd Bergmann
2019-03-05 12:18 ` Anshuman Khandual
2019-03-06 10:26   ` Arnd Bergmann
2019-03-05 23:51 ` John Hubbard
2019-03-06 10:19   ` Arnd Bergmann
2019-03-06 18:34     ` John Hubbard

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).