Skip to contentSkip to conversation

fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'

PATCH Superseded Qi Xi 3 participants 6 messages Oct 31, 2024 – Nov 1, 2024

Subsystems (5)
lore
Share & tools
lore

Qi Xi

author
#0 lore raw

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

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

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.

Fixes 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
---
 fs/proc/vmcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/proc/vmcore.c +1 -1
index 1fb213f379a5..9651f105c25b 100644
@@ -455,7 +455,7 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #endif
 }
 
-static const struct vm_operations_struct vmcore_mmap_ops = {
+static const struct vm_operations_struct __maybe_unused vmcore_mmap_ops = {
 	.fault = mmap_vmcore_fault,
 };
 
Signature · 1 line
2.33.0
maintainer
#1 lore raw
Quoted 8 lines · On Thu, 31 Oct 2024 15:27:46 +0800 Qi Xi <[email protected]> wrote:

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

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:

fs/proc/vmcore.c renamed from fs/proc/vmcore.c~a +5 -4
@@ -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?

author
#2 lore raw

PATCH v2 1/1 fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'

     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

v2: use ifdef instead of __maybe_unused

Fixes 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
---
 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +5 -4
index 1fb213f379a5..9ed1f6902c8f 100644
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #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
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * 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.
Signature · 1 line
2.33.0
#3 lore raw
Quoted 7 lines · Qi Xi

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

fs/proc/vmcore.c:458:42: warning: unused variable 'vmcore_mmap_ops'

     458 | static const struct vm_operations_struct vmcore_mmap_ops = {

v2: use ifdef instead of __maybe_unused

Changelogs should go after the '---' line, otherwise they end up in the git history.

Quoted 36 lines
Fixes 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")
---
 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +5 -4
index 1fb213f379a5..9ed1f6902c8f 100644
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #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
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * 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.
author
#4 lore raw

PATCH v3 1/1 fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

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 only defining it when CONFIG_MMU is enabled.

Fixes 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")

---
v3: move changelogs after the '---' line
v2: use ifdef instead of __maybe_unused

 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +5 -4
index 1fb213f379a5..9ed1f6902c8f 100644
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #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
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * 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.
Signature · 1 line
2.33.0
author
#5 lore raw

PATCH v3 1/1 fs/proc: Fix compile warning about variable 'vmcore_mmap_ops'

In reply to Jinjie Ruan

When build with !CONFIG_MMU, the variable 'vmcore_mmap_ops' is defined but not used:

Quoted 1 line
Quoted 1 line

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 only defining it when CONFIG_MMU is enabled.

Fixes 9cb218131de1 ("vmcore: introduce remap_oldmem_pfn_range()")

---
v3: move changelogs after the '---' line
v2: use ifdef instead of __maybe_unused

 fs/proc/vmcore.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
fs/proc/vmcore.c +5 -4
index 1fb213f379a5..9ed1f6902c8f 100644
@@ -455,10 +455,6 @@ static vm_fault_t mmap_vmcore_fault(struct vm_fault *vmf)
 #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
@@ -486,6 +482,11 @@ static inline char *vmcore_alloc_buf(size_t size)
  * 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.
Signature · 1 line
2.33.0