All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: "Jérôme Glisse" <jglisse@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Ralph Campbell <rcampbell@nvidia.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	John Hubbard <jhubbard@nvidia.com>,
	Dan Williams <dan.j.williams@intel.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mm/hmm: fix unused variable warnings
Date: Mon,  4 Mar 2019 21:00:10 +0100	[thread overview]
Message-ID: <20190304200026.1140281-1-arnd@arndb.de> (raw)

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


             reply	other threads:[~2019-03-04 20:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04 20:00 Arnd Bergmann [this message]
2019-03-05 12:18 ` [PATCH] mm/hmm: fix unused variable warnings 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190304200026.1140281-1-arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=jglisse@redhat.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rcampbell@nvidia.com \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.