KVM: guest-memfd: fix unused-function warning
Subsystems (2)
PATCH 1/1 KVM: guest-memfd: fix unused-function warning
From: Arnd Bergmann <[email protected]>
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.
--- virt/kvm/guest_memfd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
virt/kvm/guest_memfd.c +2 -3
@@ -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, };
Signature · 1 line
2.39.2
Sean Christopherson
maintainerQuoted 22 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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(structaddress_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 <[email protected]>--- virt/kvm/guest_memfd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)virt/kvm/guest_memfd.c +0
-0
virt/kvm/guest_memfd.c static int kvm_gmem_error_folio(struct address_space *mapping, · line 305
Quoted 8 lines
virt/kvm/guest_memfd.c +2
-3@@ -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),
I'd much prefer to just delete the #ifdef, e.g. so that we don't somehow end up running fallback_migrate_folio(). I have no clue why I wrapped the hook with CONFIG_MIGRATION.