public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: guest-memfd: fix unused-function warning
@ 2023-11-29 15:32 Arnd Bergmann
  2023-12-01 22:24 ` Sean Christopherson
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2023-11-29 15:32 UTC (permalink / raw)
  To: Paolo Bonzini, Yu Zhang, Isaku Yamahata, Chao Peng,
	Kirill A. Shutemov
  Cc: Arnd Bergmann, Sean Christopherson, kvm, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

With migration disabled, one function becomes unused:

virt/kvm/guest_memfd.c:262:12: error: 'kvm_gmem_migrate_folio' defined but not used [-Werror=unused-function]
  262 | static int kvm_gmem_migrate_folio(struct address_space *mapping,
      |            ^~~~~~~~~~~~~~~~~~~~~~

Replace the #ifdef around the reference with a corresponding PTR_IF() check
that lets the compiler know how it is otherwise used.

Fixes: a7800aa80ea4 ("KVM: Add KVM_CREATE_GUEST_MEMFD ioctl() for guest-specific backing memory")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 virt/kvm/guest_memfd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 16d58806e913..1a0355b95379 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -301,9 +301,8 @@ static int kvm_gmem_error_folio(struct address_space *mapping,
 
 static const struct address_space_operations kvm_gmem_aops = {
 	.dirty_folio = noop_dirty_folio,
-#ifdef CONFIG_MIGRATION
-	.migrate_folio	= kvm_gmem_migrate_folio,
-#endif
+	.migrate_folio = PTR_IF(IS_ENABLED(CONFIG_MIGRATION),
+				kvm_gmem_migrate_folio),
 	.error_remove_folio = kvm_gmem_error_folio,
 };
 
-- 
2.39.2


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

end of thread, other threads:[~2023-12-01 22:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-29 15:32 [PATCH] KVM: guest-memfd: fix unused-function warning Arnd Bergmann
2023-12-01 22:24 ` Sean Christopherson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox