[PATCH] fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'

Andrew Morton akpm at linux-foundation.org
Thu Oct 31 18:52:35 PDT 2024


On Thu, 31 Oct 2024 15:27:46 +0800 Qi Xi <xiqi2 at huawei.com> wrote:

> When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops'
> is defined but not used:
> 
> >> fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'
>      458 | static const struct vm_operations_struct vmcore_mmap_ops = {
> 
> Fix this by declaring it __maybe_unused.
> 

It's better to move the definition inside #ifdef CONFIG_MMU, perhaps this:

--- a/fs/proc/vmcore.c~a
+++ a/fs/proc/vmcore.c
@@ -457,10 +457,6 @@ static vm_fault_t mmap_vmcore_fault(stru
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
-	.fault = mmap_vmcore_fault,
-};
-
 /**
  * vmcore_alloc_buf - allocate buffer in vmalloc memory
  * @size: size of buffer
@@ -488,6 +484,11 @@ static inline char *vmcore_alloc_buf(siz
  * virtually contiguous user-space in ELF layout.
  */
 #ifdef CONFIG_MMU
+
+static const struct vm_operations_struct vmcore_mmap_ops = {
+	.fault = mmap_vmcore_fault,
+};
+
 /*
  * remap_oldmem_pfn_checked - do remap_oldmem_pfn_range replacing all pages
  * reported as not being ram with the zero page.
_


Please check and test that and send it back at us a a v2 patch?



More information about the kexec mailing list